mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
changed the order of execution for node visitors
This commit is contained in:
@@ -15,6 +15,7 @@ Backward incompatibilities:
|
||||
|
||||
Changes:
|
||||
|
||||
* changed the order of execution for node visitors
|
||||
* fixed default() filter behavior when used with strict_variables set to on
|
||||
* fixed filesystem loader compatibility with PHAR files
|
||||
* enhanced error messages when an unexpected token is parsed in an expression
|
||||
|
||||
+16
-15
@@ -56,33 +56,34 @@ class Twig_NodeTraverser
|
||||
*
|
||||
* @param Twig_NodeInterface $node A Twig_NodeInterface instance
|
||||
*/
|
||||
public function traverse(Twig_NodeInterface $node = null)
|
||||
public function traverse(Twig_NodeInterface $node)
|
||||
{
|
||||
ksort($this->visitors);
|
||||
foreach ($this->visitors as $visitors) {
|
||||
foreach ($visitors as $visitor) {
|
||||
$node = $this->traverseForVisitor($visitor, $node);
|
||||
}
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function traverseForVisitor($visitor, Twig_NodeInterface $node = null)
|
||||
{
|
||||
if (null === $node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ksort($this->visitors);
|
||||
foreach ($this->visitors as $visitors) {
|
||||
foreach ($visitors as $visitor) {
|
||||
$node = $visitor->enterNode($node, $this->env);
|
||||
}
|
||||
}
|
||||
$node = $visitor->enterNode($node, $this->env);
|
||||
|
||||
foreach ($node as $k => $n) {
|
||||
if (false !== $n = $this->traverse($n)) {
|
||||
if (false !== $n = $this->traverseForVisitor($visitor, $n)) {
|
||||
$node->setNode($k, $n);
|
||||
} else {
|
||||
$node->removeNode($k);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->visitors as $visitors) {
|
||||
foreach ($visitors as $visitor) {
|
||||
$node = $visitor->leaveNode($node, $this->env);
|
||||
}
|
||||
}
|
||||
|
||||
return $node;
|
||||
return $visitor->leaveNode($node, $this->env);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
|
||||
protected function getEnvironment($sandboxed, $templates, $tags = array(), $filters = array(), $methods = array(), $properties = array())
|
||||
{
|
||||
$loader = new Twig_Loader_Array($templates);
|
||||
$twig = new Twig_Environment($loader, array('debug' => true, 'cache' => false));
|
||||
$twig = new Twig_Environment($loader, array('debug' => true, 'cache' => false, 'autoescape' => false));
|
||||
$policy = new Twig_Sandbox_SecurityPolicy($tags, $filters, $methods, $properties);
|
||||
$twig->addExtension(new Twig_Extension_Sandbox($policy, $sandboxed));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user