[ Index ]

PHP Cross Reference of phpBB-3.3.5-deutsch

title

Body

[close]

/vendor/twig/twig/src/TokenParser/ -> ExtendsTokenParser.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of Twig.
   5   *
   6   * (c) Fabien Potencier
   7   * (c) Armin Ronacher
   8   *
   9   * For the full copyright and license information, please view the LICENSE
  10   * file that was distributed with this source code.
  11   */
  12  
  13  namespace Twig\TokenParser;
  14  
  15  use Twig\Error\SyntaxError;
  16  use Twig\Node\Node;
  17  use Twig\Token;
  18  
  19  /**
  20   * Extends a template by another one.
  21   *
  22   *  {% extends "base.html" %}
  23   */
  24  final class ExtendsTokenParser extends AbstractTokenParser
  25  {
  26      public function parse(Token $token)
  27      {
  28          $stream = $this->parser->getStream();
  29  
  30          if ($this->parser->peekBlockStack()) {
  31              throw new SyntaxError('Cannot use "extend" in a block.', $token->getLine(), $stream->getSourceContext());
  32          } elseif (!$this->parser->isMainScope()) {
  33              throw new SyntaxError('Cannot use "extend" in a macro.', $token->getLine(), $stream->getSourceContext());
  34          }
  35  
  36          if (null !== $this->parser->getParent()) {
  37              throw new SyntaxError('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext());
  38          }
  39          $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
  40  
  41          $stream->expect(Token::BLOCK_END_TYPE);
  42  
  43          return new Node();
  44      }
  45  
  46      public function getTag()
  47      {
  48          return 'extends';
  49      }
  50  }
  51  
  52  class_alias('Twig\TokenParser\ExtendsTokenParser', 'Twig_TokenParser_Extends');


Generated: Mon Oct 4 17:42:11 2021 Cross-referenced by PHPXref 0.7.1