diff options
| author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-09-02 13:54:42 -0500 |
|---|---|---|
| committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-09-02 14:01:51 -0500 |
| commit | 423357581415c7c10ed0ac51284014e839881bac (patch) | |
| tree | d8dd4ff9bd1e0daec702937b426727a4936808ee /phpBB/phpbb/template/twig/environment.php | |
| parent | 9d6370751f1b998e3da448e16c1446b33ddd17d0 (diff) | |
| download | forums-423357581415c7c10ed0ac51284014e839881bac.tar forums-423357581415c7c10ed0ac51284014e839881bac.tar.gz forums-423357581415c7c10ed0ac51284014e839881bac.tar.bz2 forums-423357581415c7c10ed0ac51284014e839881bac.tar.xz forums-423357581415c7c10ed0ac51284014e839881bac.zip | |
[ticket/11822] Use namespace lookup order for asset loading
PHPBB3-11822
Diffstat (limited to 'phpBB/phpbb/template/twig/environment.php')
| -rw-r--r-- | phpBB/phpbb/template/twig/environment.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php index b60cd72325..9a40dc2b15 100644 --- a/phpBB/phpbb/template/twig/environment.php +++ b/phpBB/phpbb/template/twig/environment.php @@ -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); + } + } } |
