mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11701] Loop variables are not passed correctly to events
PHPBB3-11701
This commit is contained in:
parent
7d8e80241c
commit
6b0b0f2a9f
2 changed files with 7 additions and 7 deletions
|
@ -191,20 +191,20 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||||
// Recursive...fix any child nodes
|
// Recursive...fix any child nodes
|
||||||
$body = $parent_class->fix_begin_tokens($body, $parent_nodes);
|
$body = $parent_class->fix_begin_tokens($body, $parent_nodes);
|
||||||
|
|
||||||
// Rename loopname vars (to prevent collisions, loop children are named (loop name)_loop_element)
|
// Rename loopname vars
|
||||||
$body = str_replace($name . '.', $name . '_loop_element.', $body);
|
$body = str_replace($name . '.', $name . '.', $body);
|
||||||
|
|
||||||
// Need the parent variable name
|
// Need the parent variable name
|
||||||
array_pop($parent_nodes);
|
array_pop($parent_nodes);
|
||||||
$parent = (!empty($parent_nodes)) ? end($parent_nodes) . '_loop_element.' : '';
|
$parent = (!empty($parent_nodes)) ? end($parent_nodes) . '.' : '';
|
||||||
|
|
||||||
if ($subset !== '')
|
if ($subset !== '')
|
||||||
{
|
{
|
||||||
$subset = '|subset(' . $subset . ')';
|
$subset = '|subset(' . $subset . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn into a Twig for loop, using (loop name)_loop_element for each child
|
// Turn into a Twig for loop
|
||||||
return "{% for {$name}_loop_element in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
return "{% for {$name} in loops.{$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
||||||
};
|
};
|
||||||
|
|
||||||
// Replace <!-- BEGINELSE --> correctly, only needs to be done once
|
// Replace <!-- BEGINELSE --> correctly, only needs to be done once
|
||||||
|
|
|
@ -429,15 +429,15 @@ class phpbb_template_twig implements phpbb_template
|
||||||
|
|
||||||
$vars = array_merge(
|
$vars = array_merge(
|
||||||
$context_vars['.'][0], // To get normal vars
|
$context_vars['.'][0], // To get normal vars
|
||||||
$context_vars, // To get loops
|
|
||||||
array(
|
array(
|
||||||
'definition' => new phpbb_template_twig_definition(),
|
'definition' => new phpbb_template_twig_definition(),
|
||||||
'user' => $this->user,
|
'user' => $this->user,
|
||||||
|
'loops' => $context_vars, // To get loops
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
unset($vars['.']);
|
unset($vars['loops']['.']);
|
||||||
|
|
||||||
return $vars;
|
return $vars;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue