triggerFilter -> pass by reference (faster x5)

This commit is contained in:
slawkens 2025-05-08 18:34:36 +02:00
parent 99997eb57d
commit 5b4b7b8a97
4 changed files with 5 additions and 7 deletions

View File

@ -575,7 +575,7 @@ function template_footer(): string
$footer[] = base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4='); $footer[] = base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4=');
global $hooks; global $hooks;
$footer = $hooks->triggerFilter(HOOK_FILTER_THEME_FOOTER, $footer); $hooks->triggerFilter(HOOK_FILTER_THEME_FOOTER, $footer);
return implode('<br/>', $footer); return implode('<br/>', $footer);
} }

View File

@ -37,7 +37,7 @@ class Hook
return !isset($ret) || $ret == 1 || $ret; return !isset($ret) || $ret == 1 || $ret;
} }
public function executeFilter(...$args) { public function executeFilter(&$args) {
return include BASE . $this->_file; return include BASE . $this->_file;
} }

View File

@ -30,7 +30,7 @@ class Hooks
return $ret; return $ret;
} }
public function triggerFilter($type, $args = []) public function triggerFilter($type, &...$args)
{ {
if(isset(self::$_hooks[$type])) { if(isset(self::$_hooks[$type])) {
foreach(self::$_hooks[$type] as $hook) { foreach(self::$_hooks[$type] as $hook) {
@ -38,8 +38,6 @@ class Hooks
$args = $hook->executeFilter(...$args); $args = $hook->executeFilter(...$args);
} }
} }
return $args;
} }
public function exist($type): bool { public function exist($type): bool {

View File

@ -11,7 +11,7 @@ class EnvironmentBridge extends Environment
global $hooks; global $hooks;
$context['viewName'] = $name; $context['viewName'] = $name;
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_DISPLAY, $context); $hooks->triggerFilter(HOOK_FILTER_TWIG_DISPLAY, $context);
parent::display($name, $context); parent::display($name, $context);
} }
@ -21,7 +21,7 @@ class EnvironmentBridge extends Environment
global $hooks; global $hooks;
$context['viewName'] = $name; $context['viewName'] = $name;
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_RENDER, $context); $hooks->triggerFilter(HOOK_FILTER_TWIG_RENDER, $context);
return parent::render($name, $context); return parent::render($name, $context);
} }