Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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: 09.10.2024, 12:56 - Dateigröße: 2.44 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   
16  /**
17   * Token Parser for the 'transchoice' tag.
18   *
19   * @author Fabien Potencier <fabien@symfony.com>
20   */
21  class TransChoiceTokenParser extends TransTokenParser
22  {
23      /**
24       * Parses a token and returns a node.
25       *
26       * @param \Twig_Token $token A Twig_Token instance
27       *
28       * @return \Twig_Node A Twig_Node instance
29       *
30       * @throws \Twig_Error_Syntax
31       */
32      public function parse(\Twig_Token $token)
33      {
34          $lineno = $token->getLine();
35          $stream = $this->parser->getStream();
36   
37          $vars = new \Twig_Node_Expression_Array(array(), $lineno);
38   
39          $count = $this->parser->getExpressionParser()->parseExpression();
40   
41          $domain = null;
42          $locale = null;
43   
44          if ($stream->test('with')) {
45              // {% transchoice count with vars %}
46              $stream->next();
47              $vars = $this->parser->getExpressionParser()->parseExpression();
48          }
49   
50          if ($stream->test('from')) {
51              // {% transchoice count from "messages" %}
52              $stream->next();
53              $domain = $this->parser->getExpressionParser()->parseExpression();
54          }
55   
56          if ($stream->test('into')) {
57              // {% transchoice count into "fr" %}
58              $stream->next();
59              $locale = $this->parser->getExpressionParser()->parseExpression();
60          }
61   
62          $stream->expect(\Twig_Token::BLOCK_END_TYPE);
63   
64          $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
65   
66          if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
67              throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getFilename());
68          }
69   
70          $stream->expect(\Twig_Token::BLOCK_END_TYPE);
71   
72          return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag());
73      }
74   
75      public function decideTransChoiceFork($token)
76      {
77          return $token->test(array('endtranschoice'));
78      }
79   
80      /**
81       * Gets the tag name associated with this token parser.
82       *
83       * @return string The tag name
84       */
85      public function getTag()
86      {
87          return 'transchoice';
88      }
89  }
90