1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 20:13:22 +01:00

[feature/twig] If DEBUG, EVENT will always look for new/missing tpl event files

If debug mode is enabled, lets check for new/removed EVENT templates on
page load rather than at compile. This is slower, but makes developing
extensions easier (no need to purge the cache when a new event template
file is added)

PHPBB3-11598
This commit is contained in:
Nathan Guse 2013-07-06 16:26:56 -05:00
parent 921d44aa4d
commit 0894a13770

View File

@ -43,17 +43,37 @@ class phpbb_template_twig_node_event extends Twig_Node
{
$ext_namespace = str_replace('/', '_', $ext_namespace);
if ($this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
if (defined('DEBUG'))
{
// If debug mode is enabled, lets check for new/removed EVENT
// templates on page load rather than at compile. This is
// slower, but makes developing extensions easier (no need to
// purge the cache when a new event template file is added)
$compiler
->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")
->indent()
;
}
if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{
$compiler
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
// We set the namespace lookup order to be this extension first, then the main path
->write("\$this->env->setNamespaceLookUpOrder(array('" . $ext_namespace . "', '__main__'));\n")
->write("\$this->env->loadTemplate('@" . $ext_namespace . "/" . $location . ".html')->display(\$context);\n")
->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
;
}
if (defined('DEBUG'))
{
$compiler
->outdent()
->write("}\n\n")
;
}
}
}
}