diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
commit | 46b77928f746a4231d064774b5b67fd892c7ce86 (patch) | |
tree | e3ea690b3f0def1744ddae758923cf92171ef985 /vendor/symfony/twig-bridge/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php | |
parent | 68abd9c71b1d2f7bb2e9d21819584d1d15005b25 (diff) | |
download | wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.gz wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.zst wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.zip |
rm vendor
Diffstat (limited to 'vendor/symfony/twig-bridge/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php')
-rw-r--r-- | vendor/symfony/twig-bridge/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php deleted file mode 100644 index a11681c2..00000000 --- a/vendor/symfony/twig-bridge/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
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 Symfony\Bridge\Twig\TokenParser; | ||
13 | |||
14 | use Symfony\Bridge\Twig\Node\TransNode; | ||
15 | |||
16 | /** | ||
17 | * Token Parser for the 'trans' tag. | ||
18 | * | ||
19 | * @author Fabien Potencier <fabien@symfony.com> | ||
20 | */ | ||
21 | class TransTokenParser extends \Twig_TokenParser | ||
22 | { | ||
23 | /** | ||
24 | * Parses a token and returns a node. | ||
25 | * | ||
26 | * @param \Twig_Token $token A Twig_Token instance | ||
27 | * | ||
28 | * @return \Twig_NodeInterface A Twig_NodeInterface 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 | $domain = null; | ||
39 | $locale = null; | ||
40 | if (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) { | ||
41 | if ($stream->test('with')) { | ||
42 | // {% trans with vars %} | ||
43 | $stream->next(); | ||
44 | $vars = $this->parser->getExpressionParser()->parseExpression(); | ||
45 | } | ||
46 | |||
47 | if ($stream->test('from')) { | ||
48 | // {% trans from "messages" %} | ||
49 | $stream->next(); | ||
50 | $domain = $this->parser->getExpressionParser()->parseExpression(); | ||
51 | } | ||
52 | |||
53 | if ($stream->test('into')) { | ||
54 | // {% trans into "fr" %} | ||
55 | $stream->next(); | ||
56 | $locale = $this->parser->getExpressionParser()->parseExpression(); | ||
57 | } elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) { | ||
58 | throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with" or "from" keyword.'); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | // {% trans %}message{% endtrans %} | ||
63 | $stream->expect(\Twig_Token::BLOCK_END_TYPE); | ||
64 | $body = $this->parser->subparse(array($this, 'decideTransFork'), true); | ||
65 | |||
66 | if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) { | ||
67 | throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text'); | ||
68 | } | ||
69 | |||
70 | $stream->expect(\Twig_Token::BLOCK_END_TYPE); | ||
71 | |||
72 | return new TransNode($body, $domain, null, $vars, $locale, $lineno, $this->getTag()); | ||
73 | } | ||
74 | |||
75 | public function decideTransFork($token) | ||
76 | { | ||
77 | return $token->test(array('endtrans')); | ||
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 'trans'; | ||
88 | } | ||
89 | } | ||