Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

UseTokenParser.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 1.97 KiB


01  <?php
02   
03  /*
04   * This file is part of Twig.
05   *
06   * (c) Fabien Potencier
07   *
08   * For the full copyright and license information, please view the LICENSE
09   * file that was distributed with this source code.
10   */
11   
12  namespace Twig\TokenParser;
13   
14  use Twig\Error\SyntaxError;
15  use Twig\Node\Expression\ConstantExpression;
16  use Twig\Node\Node;
17  use Twig\Token;
18   
19  /**
20   * Imports blocks defined in another template into the current template.
21   *
22   *    {% extends "base.html" %}
23   *
24   *    {% use "blocks.html" %}
25   *
26   *    {% block title %}{% endblock %}
27   *    {% block content %}{% endblock %}
28   *
29   * @see https://twig.symfony.com/doc/templates.html#horizontal-reuse for details.
30   */
31  final class UseTokenParser extends AbstractTokenParser
32  {
33      public function parse(Token $token)
34      {
35          $template = $this->parser->getExpressionParser()->parseExpression();
36          $stream = $this->parser->getStream();
37   
38          if (!$template instanceof ConstantExpression) {
39              throw new SyntaxError('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
40          }
41   
42          $targets = [];
43          if ($stream->nextIf('with')) {
44              do {
45                  $name = $stream->expect(/* Token::NAME_TYPE */ 5)->getValue();
46   
47                  $alias = $name;
48                  if ($stream->nextIf('as')) {
49                      $alias = $stream->expect(/* Token::NAME_TYPE */ 5)->getValue();
50                  }
51   
52                  $targets[$name] = new ConstantExpression($alias, -1);
53   
54                  if (!$stream->nextIf(/* Token::PUNCTUATION_TYPE */ 9, ',')) {
55                      break;
56                  }
57              } while (true);
58          }
59   
60          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
61   
62          $this->parser->addTrait(new Node(['template' => $template, 'targets' => new Node($targets)]));
63   
64          return new Node();
65      }
66   
67      public function getTag()
68      {
69          return 'use';
70      }
71  }
72   
73  class_alias('Twig\TokenParser\UseTokenParser', 'Twig_TokenParser_Use');
74