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

Breadcrumb

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

class BlockNode

Represents a block node.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

  • class \Twig\Node\Node implements \Twig\Node\Countable, \Twig\Node\IteratorAggregate
    • class \Twig\Node\BlockNode extends \Twig\Node\Node

Expanded class hierarchy of BlockNode

4 files declare their use of BlockNode
BlockTokenParser.php in vendor/twig/twig/src/TokenParser/BlockTokenParser.php
EscaperNodeVisitor.php in vendor/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php
Parser.php in vendor/twig/twig/src/Parser.php
ProfilerNodeVisitor.php in vendor/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php

File

vendor/twig/twig/src/Node/BlockNode.php, line 23

Namespace

Twig\Node
View source
class BlockNode extends Node {
    public function __construct(string $name, Node $body, int $lineno) {
        parent::__construct([
            'body' => $body,
        ], [
            'name' => $name,
        ], $lineno);
    }
    public function compile(Compiler $compiler) : void {
        $compiler->addDebugInfo($this)
            ->write("/**\n")
            ->write(" * @return iterable<null|scalar|\\Stringable>\n")
            ->write(" */\n")
            ->write(\sprintf("public function block_%s(array \$context, array \$blocks = []): iterable\n", $this->getAttribute('name')), "{\n")
            ->indent()
            ->write("\$macros = \$this->macros;\n");
        $compiler->subcompile($this->getNode('body'))
            ->write("yield from [];\n")
            ->outdent()
            ->write("}\n\n");
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
BlockNode::compile public function Overrides Node::compile
BlockNode::__construct public function Overrides Node::__construct
Node::$attributeNameDeprecations private property @var array&lt;string, NameDeprecation&gt;
Node::$attributes protected property
Node::$lineno protected property
Node::$nodeNameDeprecations private property @var array&lt;string, NameDeprecation&gt;
Node::$nodes protected property
Node::$sourceContext private property
Node::$tag protected property
Node::count public function
Node::deprecateAttribute public function
Node::deprecateNode public function
Node::getAttribute public function
Node::getIterator public function
Node::getNode public function
Node::getNodeTag public function
Node::getSourceContext public function
Node::getTemplateLine public function
Node::getTemplateName public function
Node::hasAttribute public function
Node::hasNode public function
Node::removeAttribute public function
Node::removeNode public function
Node::setAttribute public function
Node::setNode public function 1
Node::setNodeTag public function @internal
Node::setSourceContext public function
Node::__toString public function
RSS feed
Powered by Drupal