[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

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

   1  <?php
   2  
   3  /*
   4   * This file is part of Twig.
   5   *
   6   * (c) Fabien Potencier
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Twig\TokenParser;
  13  
  14  use Twig\Node\Expression\AssignNameExpression;
  15  use Twig\Node\ImportNode;
  16  use Twig\Token;
  17  
  18  /**
  19   * Imports macros.
  20   *
  21   *   {% import 'forms.html' as forms %}
  22   *
  23   * @final
  24   */
  25  class ImportTokenParser extends AbstractTokenParser
  26  {
  27      public function parse(Token $token)
  28      {
  29          $macro = $this->parser->getExpressionParser()->parseExpression();
  30          $this->parser->getStream()->expect(Token::NAME_TYPE, 'as');
  31          $var = new AssignNameExpression($this->parser->getStream()->expect(Token::NAME_TYPE)->getValue(), $token->getLine());
  32          $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
  33  
  34          $this->parser->addImportedSymbol('template', $var->getAttribute('name'));
  35  
  36          return new ImportNode($macro, $var, $token->getLine(), $this->getTag());
  37      }
  38  
  39      public function getTag()
  40      {
  41          return 'import';
  42      }
  43  }
  44  
  45  class_alias('Twig\TokenParser\ImportTokenParser', 'Twig_TokenParser_Import');


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1