mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
Merge pull request #1690 from EXreaction/ticket/11822
[ticket/11822] Use namespace lookup order for asset loading
This commit is contained in:
commit
484d457363
2 changed files with 37 additions and 2 deletions
|
@ -137,4 +137,39 @@ class phpbb_template_twig_environment extends Twig_Environment
|
||||||
return parent::loadTemplate($name, $index);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,10 @@ abstract class phpbb_template_twig_node_includeasset extends Twig_Node
|
||||||
->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n")
|
->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n")
|
||||||
->write("if (!file_exists(\$local_file)) {\n")
|
->write("if (!file_exists(\$local_file)) {\n")
|
||||||
->indent()
|
->indent()
|
||||||
->write("\$local_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_path);\n")
|
->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n")
|
||||||
->write("\$asset->set_path(\$local_file, true);\n")
|
->write("\$asset->set_path(\$local_file, true);\n")
|
||||||
->outdent()
|
->outdent()
|
||||||
->write("\$asset->add_assets_version({$config['assets_version']});\n")
|
->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
|
||||||
->write("\$asset_file = \$asset->get_url();\n")
|
->write("\$asset_file = \$asset->get_url();\n")
|
||||||
->write("}\n")
|
->write("}\n")
|
||||||
->outdent()
|
->outdent()
|
||||||
|
|
Loading…
Add table
Reference in a new issue