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

Breadcrumb

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

class ExtendsTokenParser

Extends a template by another one.

{% extends "base.html" %}

@internal

Hierarchy

  • class \Twig\TokenParser\AbstractTokenParser implements \Twig\TokenParser\TokenParserInterface
    • class \Twig\TokenParser\ExtendsTokenParser extends \Twig\TokenParser\AbstractTokenParser

Expanded class hierarchy of ExtendsTokenParser

1 file declares its use of ExtendsTokenParser
CoreExtension.php in vendor/twig/twig/src/Extension/CoreExtension.php

File

vendor/twig/twig/src/TokenParser/ExtendsTokenParser.php, line 27

Namespace

Twig\TokenParser
View source
final class ExtendsTokenParser extends AbstractTokenParser {
    public function parse(Token $token) : Node {
        $stream = $this->parser
            ->getStream();
        if ($this->parser
            ->peekBlockStack()) {
            throw new SyntaxError('Cannot use "extend" in a block.', $token->getLine(), $stream->getSourceContext());
        }
        elseif (!$this->parser
            ->isMainScope()) {
            throw new SyntaxError('Cannot use "extend" in a macro.', $token->getLine(), $stream->getSourceContext());
        }
        $this->parser
            ->setParent($this->parser
            ->getExpressionParser()
            ->parseExpression());
        $stream->expect(Token::BLOCK_END_TYPE);
        return new EmptyNode($token->getLine());
    }
    public function getTag() : string {
        return 'extends';
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AbstractTokenParser::$parser protected property
AbstractTokenParser::setParser public function Sets the parser associated with this token parser. Overrides TokenParserInterface::setParser
ExtendsTokenParser::getTag public function Gets the tag name associated with this token parser. Overrides TokenParserInterface::getTag
ExtendsTokenParser::parse public function Parses a token and returns a node. Overrides TokenParserInterface::parse
RSS feed
Powered by Drupal