You are here

protected function Twig_NodeTraverser::traverseForVisitor in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/lib/Twig/NodeTraverser.php \Twig_NodeTraverser::traverseForVisitor()
1 call to Twig_NodeTraverser::traverseForVisitor()
Twig_NodeTraverser::traverse in vendor/twig/twig/lib/Twig/NodeTraverser.php
Traverses a node and calls the registered visitors.

File

vendor/twig/twig/lib/Twig/NodeTraverser.php, line 71

Class

Twig_NodeTraverser
Twig_NodeTraverser is a node traverser.

Code

protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null) {
  if (null === $node) {
    return;
  }
  $node = $visitor
    ->enterNode($node, $this->env);
  foreach ($node as $k => $n) {
    if (false !== ($n = $this
      ->traverseForVisitor($visitor, $n))) {
      $node
        ->setNode($k, $n);
    }
    else {
      $node
        ->removeNode($k);
    }
  }
  return $visitor
    ->leaveNode($node, $this->env);
}