- Affected version
- 2.0.0 RC1
Per the title, the value that gets passed to the
What is passed to the event as
Because of this, I've had to include the following boilerplate in all of my
Any chance at changing the behavior here so the boilerplate isn't necessary?
template_macro_pre_render
event as $globalVars
isn't always the value that winds up as $__globals
in the macro. As far as I can tell, this can happen during macro nesting because of code in XF\Template\Templater::setupBaseParamsForMacro()
.What is passed to the event as
$globalVars
is actually passed to that method as $parentVars
, and the resulting value of $__globals
in the macro depends on whether or not a __globals
sub-array is present (which can vary depending on how the macro was called).Because of this, I've had to include the following boilerplate in all of my
template_macro_pre_render
events to make sure the value is actually available in the macro:
PHP:
if (isset($globalVars['__globals'])) {
$__globals = &$globalVars['__globals'];
} else {
$__globals = &$globalVars;
}
$__globals['key'] = "value";
Any chance at changing the behavior here so the boilerplate isn't necessary?