1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-28 10:40:28 +02:00

[ticket/11822] Use namespace lookup order for asset loading

PHPBB3-11822
This commit is contained in:
Nathan Guse
2013-09-02 13:54:42 -05:00
parent 9d6370751f
commit 4233575814
2 changed files with 37 additions and 2 deletions

View File

@@ -137,4 +137,39 @@ class phpbb_template_twig_environment extends Twig_Environment
return parent::loadTemplate($name, $index);
}
}
/**
* Finds a template by name.
*
* @param string $name The template name
* @return string
*/
public function findTemplate($name)
{
if (strpos($name, '@') === false)
{
foreach ($this->getNamespaceLookUpOrder() as $namespace)
{
try
{
if ($namespace === '__main__')
{
return parent::getLoader()->getCacheKey($name);
}
return parent::getLoader()->getCacheKey('@' . $namespace . '/' . $name);
}
catch (Twig_Error_Loader $e)
{
}
}
// We were unable to load any templates
throw $e;
}
else
{
return parent::getLoader()->getCacheKey($name);
}
}
}