[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/vendor/twig/twig/src/TokenParser/ -> IncludeTokenParser.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\Node\IncludeNode;
  16  use Twig\Token;
  17  
  18  /**
  19   * Includes a template.
  20   *
  21   *   {% include 'header.html' %}
  22   *     Body
  23   *   {% include 'footer.html' %}
  24   */
  25  class IncludeTokenParser extends AbstractTokenParser
  26  {
  27      public function parse(Token $token)
  28      {
  29          $expr = $this->parser->getExpressionParser()->parseExpression();
  30  
  31          list($variables, $only, $ignoreMissing) = $this->parseArguments();
  32  
  33          return new IncludeNode($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
  34      }
  35  
  36      protected function parseArguments()
  37      {
  38          $stream = $this->parser->getStream();
  39  
  40          $ignoreMissing = false;
  41          if ($stream->nextIf(Token::NAME_TYPE, 'ignore')) {
  42              $stream->expect(Token::NAME_TYPE, 'missing');
  43  
  44              $ignoreMissing = true;
  45          }
  46  
  47          $variables = null;
  48          if ($stream->nextIf(Token::NAME_TYPE, 'with')) {
  49              $variables = $this->parser->getExpressionParser()->parseExpression();
  50          }
  51  
  52          $only = false;
  53          if ($stream->nextIf(Token::NAME_TYPE, 'only')) {
  54              $only = true;
  55          }
  56  
  57          $stream->expect(Token::BLOCK_END_TYPE);
  58  
  59          return [$variables, $only, $ignoreMissing];
  60      }
  61  
  62      public function getTag()
  63      {
  64          return 'include';
  65      }
  66  }
  67  
  68  class_alias('Twig\TokenParser\IncludeTokenParser', 'Twig_TokenParser_Include');


Generated: Tue Apr 7 19:42:26 2020 Cross-referenced by PHPXref 0.7.1