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

TransChoiceTokenParser.php

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


01  <?php
02   
03  /*
04   * This file is part of the Symfony package.
05   *
06   * (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Bridge\Twig\TokenParser;
13   
14  use Symfony\Bridge\Twig\Node\TransNode;
15  use Twig\Error\SyntaxError;
16  use Twig\Node\Expression\AbstractExpression;
17  use Twig\Node\Expression\ArrayExpression;
18  use Twig\Node\TextNode;
19  use Twig\Token;
20   
21  /**
22   * Token Parser for the 'transchoice' tag.
23   *
24   * @author Fabien Potencier <fabien@symfony.com>
25   */
26  class TransChoiceTokenParser extends TransTokenParser
27  {
28      /**
29       * {@inheritdoc}
30       */
31      public function parse(Token $token)
32      {
33          $lineno = $token->getLine();
34          $stream = $this->parser->getStream();
35   
36          $vars = new ArrayExpression([], $lineno);
37   
38          $count = $this->parser->getExpressionParser()->parseExpression();
39   
40          $domain = null;
41          $locale = null;
42   
43          if ($stream->test('with')) {
44              // {% transchoice count with vars %}
45              $stream->next();
46              $vars = $this->parser->getExpressionParser()->parseExpression();
47          }
48   
49          if ($stream->test('from')) {
50              // {% transchoice count from "messages" %}
51              $stream->next();
52              $domain = $this->parser->getExpressionParser()->parseExpression();
53          }
54   
55          if ($stream->test('into')) {
56              // {% transchoice count into "fr" %}
57              $stream->next();
58              $locale = $this->parser->getExpressionParser()->parseExpression();
59          }
60   
61          $stream->expect(Token::BLOCK_END_TYPE);
62   
63          $body = $this->parser->subparse([$this, 'decideTransChoiceFork'], true);
64   
65          if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
66              throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
67          }
68   
69          $stream->expect(Token::BLOCK_END_TYPE);
70   
71          return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag());
72      }
73   
74      public function decideTransChoiceFork($token)
75      {
76          return $token->test(['endtranschoice']);
77      }
78   
79      /**
80       * {@inheritdoc}
81       */
82      public function getTag()
83      {
84          return 'transchoice';
85      }
86  }
87