mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00: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:
parent
921d44aa4d
commit
0894a13770
1 changed files with 23 additions and 3 deletions
|
@ -43,17 +43,37 @@ class phpbb_template_twig_node_event extends Twig_Node
|
||||||
{
|
{
|
||||||
$ext_namespace = str_replace('/', '_', $ext_namespace);
|
$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
|
$compiler
|
||||||
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
|
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
|
||||||
|
|
||||||
// We set the namespace lookup order to be this extension first, then the main path
|
// 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->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
|
||||||
->write("\$this->env->loadTemplate('@" . $ext_namespace . "/" . $location . ".html')->display(\$context);\n")
|
->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")
|
||||||
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
|
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined('DEBUG'))
|
||||||
|
{
|
||||||
|
$compiler
|
||||||
|
->outdent()
|
||||||
|
->write("}\n\n")
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue