Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EscaperNodeVisitor.php

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\NodeVisitor

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal