]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/twig-bridge/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / twig-bridge / Symfony / Bridge / Twig / Tests / NodeVisitor / TwigNodeProvider.php
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\Tests\NodeVisitor;
13
14 use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
15 use Symfony\Bridge\Twig\Node\TransNode;
16
17 class TwigNodeProvider
18 {
19 public static function getModule($content)
20 {
21 return new \Twig_Node_Module(
22 new \Twig_Node_Expression_Constant($content, 0),
23 null,
24 new \Twig_Node_Expression_Array(array(), 0),
25 new \Twig_Node_Expression_Array(array(), 0),
26 new \Twig_Node_Expression_Array(array(), 0),
27 null,
28 null
29 );
30 }
31
32 public static function getTransFilter($message, $domain = null)
33 {
34 $arguments = $domain ? array(
35 new \Twig_Node_Expression_Array(array(), 0),
36 new \Twig_Node_Expression_Constant($domain, 0),
37 ) : array();
38
39 return new \Twig_Node_Expression_Filter(
40 new \Twig_Node_Expression_Constant($message, 0),
41 new \Twig_Node_Expression_Constant('trans', 0),
42 new \Twig_Node($arguments),
43 0
44 );
45 }
46
47 public static function getTransChoiceFilter($message, $domain = null)
48 {
49 $arguments = $domain ? array(
50 new \Twig_Node_Expression_Constant(0, 0),
51 new \Twig_Node_Expression_Array(array(), 0),
52 new \Twig_Node_Expression_Constant($domain, 0),
53 ) : array();
54
55 return new \Twig_Node_Expression_Filter(
56 new \Twig_Node_Expression_Constant($message, 0),
57 new \Twig_Node_Expression_Constant('transchoice', 0),
58 new \Twig_Node($arguments),
59 0
60 );
61 }
62
63 public static function getTransTag($message, $domain = null)
64 {
65 return new TransNode(
66 new \Twig_Node_Body(array(), array('data' => $message)),
67 $domain ? new \Twig_Node_Expression_Constant($domain, 0) : null
68 );
69 }
70
71 public static function getTransDefaultDomainTag($domain)
72 {
73 return new TransDefaultDomainNode(
74 new \Twig_Node_Expression_Constant($domain, 0)
75 );
76 }
77 }