Compare commits

..

No commits in common. "ccbdfb49c7dbcbfd28d360f307ab7c2ef79f998a" and "3a5247d01b8678bb48afc6c94dbbba9140c2e90f" have entirely different histories.

6 changed files with 21 additions and 35 deletions

View file

@ -52,8 +52,11 @@ class event extends \Twig\Node\Node
foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path)
{
$ext_namespace = str_replace('/', '_', $ext_namespace);
$priority_key = $this->template_event_priority_array[$ext_namespace][$location] ?? 0;
$template_events[$priority_key][] = $ext_namespace;
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{
$priority_key = $this->template_event_priority_array[$ext_namespace][$location] ?? 0;
$template_events[$priority_key][] = $ext_namespace;
}
}
krsort($template_events);
@ -72,16 +75,13 @@ class event extends \Twig\Node\Node
->indent();
}
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{
$compiler
->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
$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(\$this->env->getTemplateClass('@{$ext_namespace}/{$location}.html'), '@{$ext_namespace}/{$location}.html')->display(\$context);\n")
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\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(\$this->env->getTemplateClass('@{$ext_namespace}/{$location}.html'), '@{$ext_namespace}/{$location}.html')->display(\$context);\n")
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n");
if ($this->environment->isDebug())
{

View file

@ -42,7 +42,7 @@ class event extends \Twig\TokenParser\AbstractTokenParser
* In case of equal priority values, corresponding template event listeners will be handled in default compilation order.
* If not set, template event listener priority will be assigned to the value of 0.
*
* @event core.twig_event_tokenparser_constructor
* @event core.twig_tokenparser_constructor
* @var array template_event_priority_array Array with template event priority assignments per extension namespace
* Usage:
* '<author>_<extension_name>' => [
@ -50,31 +50,17 @@ class event extends \Twig\TokenParser\AbstractTokenParser
* ],
*
* Example:
* class template_event_order implements EventSubscriberInterface
* {
* static public function getSubscribedEvents()
* {
* return [
* 'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
* ];
* }
*
* public function set_template_event_priority($event)
* {
* $template_event_priority_array = $event['template_event_priority_array'];
* $template_event_priority_array['vendor_name'] = [
* 'event/navbar_header_quick_links_after' => -1,
* ];
* $event['template_event_priority_array'] = $template_event_priority_array;
* }
* }
* 'phpbb_viglink' => [
* 'event/acp_help_phpbb_stats_after' => 80,
* 'event/overall_footer_after' => 100,
* ],
*
* @since 4.0.0-a1
*/
if ($this->phpbb_dispatcher)
{
$vars = ['template_event_priority_array'];
extract($this->phpbb_dispatcher->trigger_event('core.twig_event_tokenparser_constructor', compact($vars)));
extract($this->phpbb_dispatcher->trigger_event('core.twig_tokenparser_constructor', compact($vars)));
}
$this->template_event_priority_array = $template_event_priority_array;

View file

@ -23,7 +23,7 @@ class template_event_order implements EventSubscriberInterface
static public function getSubscribedEvents()
{
return array(
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
'core.twig_tokenparser_constructor' => 'set_template_event_priority',
);
}

View file

@ -23,7 +23,7 @@ class template_event_order implements EventSubscriberInterface
static public function getSubscribedEvents()
{
return array(
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
'core.twig_tokenparser_constructor' => 'set_template_event_priority',
);
}

View file

@ -23,7 +23,7 @@ class template_event_order implements EventSubscriberInterface
static public function getSubscribedEvents()
{
return array(
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
'core.twig_tokenparser_constructor' => 'set_template_event_priority',
);
}

View file

@ -23,7 +23,7 @@ class template_event_order implements EventSubscriberInterface
static public function getSubscribedEvents()
{
return array(
'core.twig_event_tokenparser_constructor' => 'set_template_event_priority',
'core.twig_tokenparser_constructor' => 'set_template_event_priority',
);
}