Called before child nodes are visited.
Twig_NodeInterface $node The node to visit:
Twig_Environment $env The Twig environment instance:
Twig_NodeInterface The modified node
Overrides Twig_NodeVisitorInterface::enterNode
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) {
if ($node instanceof Twig_Node_Module) {
$this->inAModule = true;
$this->tags = array();
$this->filters = array();
$this->functions = array();
return $node;
}
elseif ($this->inAModule) {
// look for tags
if ($node
->getNodeTag()) {
$this->tags[] = $node
->getNodeTag();
}
// look for filters
if ($node instanceof Twig_Node_Expression_Filter) {
$this->filters[] = $node
->getNode('filter')
->getAttribute('value');
}
// look for functions
if ($node instanceof Twig_Node_Expression_Function) {
$this->functions[] = $node
->getAttribute('name');
}
// wrap print to check __toString() calls
if ($node instanceof Twig_Node_Print) {
return new Twig_Node_SandboxedPrint($node
->getNode('expr'), $node
->getLine(), $node
->getNodeTag());
}
}
return $node;
}