function ProfilerNodeVisitor::leaveNode
Overrides NodeVisitorInterface::leaveNode
File
-
vendor/
twig/ twig/ src/ Profiler/ NodeVisitor/ ProfilerNodeVisitor.php, line 44
Class
- ProfilerNodeVisitor
- @author Fabien Potencier <fabien@symfony.com>
Namespace
Twig\Profiler\NodeVisitorCode
public function leaveNode(Node $node, Environment $env) : ?Node {
if ($node instanceof ModuleNode) {
$node->setNode('display_start', new Nodes([
new EnterProfileNode($this->extensionName, Profile::TEMPLATE, $node->getTemplateName(), $this->varName),
$node->getNode('display_start'),
]));
$node->setNode('display_end', new Nodes([
new LeaveProfileNode($this->varName),
$node->getNode('display_end'),
]));
}
elseif ($node instanceof BlockNode) {
$node->setNode('body', new BodyNode([
new EnterProfileNode($this->extensionName, Profile::BLOCK, $node->getAttribute('name'), $this->varName),
$node->getNode('body'),
new LeaveProfileNode($this->varName),
]));
}
elseif ($node instanceof MacroNode) {
$node->setNode('body', new BodyNode([
new EnterProfileNode($this->extensionName, Profile::MACRO, $node->getAttribute('name'), $this->varName),
$node->getNode('body'),
new LeaveProfileNode($this->varName),
]));
}
return $node;
}