Fixing variables being shared between plugins
If two plugins used the same hook, the variables they use aren't cleaned out in between running each of them. This is a super simple change creating a placeholder composite object that doesn't retain any changes between plugins.
This commit is contained in:
parent
7e2598cedb
commit
6cadf82a63
|
|
@ -45,17 +45,18 @@ class HookHelper extends Base
|
|||
$buffer = '';
|
||||
|
||||
foreach ($this->hook->getListeners($hook) as $params) {
|
||||
$currentVariables = $variables;
|
||||
if (! empty($params['variables'])) {
|
||||
$variables = array_merge($variables, $params['variables']);
|
||||
$currentVariables = array_merge($variables, $params['variables']);
|
||||
} elseif (! empty($params['callable'])) {
|
||||
$result = call_user_func_array($params['callable'], $variables);
|
||||
|
||||
if (is_array($result)) {
|
||||
$variables = array_merge($variables, $result);
|
||||
$currentVariables = array_merge($variables, $result);
|
||||
}
|
||||
}
|
||||
|
||||
$buffer .= $this->template->render($params['template'], $variables);
|
||||
$buffer .= $this->template->render($params['template'], $currentVariables);
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
|
|
|
|||
Loading…
Reference in New Issue