function EscaperNodeVisitor::enterNode
Overrides NodeVisitorInterface::enterNode
File
-
vendor/
twig/ twig/ src/ NodeVisitor/ EscaperNodeVisitor.php, line 49
Class
- EscaperNodeVisitor
- @author Fabien Potencier <fabien@symfony.com>
Namespace
Twig\NodeVisitorCode
public function enterNode(Node $node, Environment $env) : Node {
if ($node instanceof ModuleNode) {
if ($env->hasExtension(EscaperExtension::class) && ($defaultStrategy = $env->getExtension(EscaperExtension::class)
->getDefaultStrategy($node->getTemplateName()))) {
$this->defaultStrategy = $defaultStrategy;
}
$this->safeVars = [];
$this->blocks = [];
}
elseif ($node instanceof AutoEscapeNode) {
$this->statusStack[] = $node->getAttribute('value');
}
elseif ($node instanceof BlockNode) {
$this->statusStack[] = $this->blocks[$node->getAttribute('name')] ?? $this->needEscaping();
}
elseif ($node instanceof ImportNode) {
$this->safeVars[] = $node->getNode('var')
->getNode('var')
->getAttribute('name');
}
return $node;
}