1 | <?php |
||
22 | class GimmeExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var LoaderInterface |
||
26 | */ |
||
27 | protected $loader; |
||
28 | |||
29 | /** |
||
30 | * @var Context |
||
31 | */ |
||
32 | protected $context; |
||
33 | |||
34 | /** |
||
35 | * GimmeExtension constructor. |
||
36 | * |
||
37 | * @param Context $context |
||
38 | * @param LoaderInterface $loader |
||
39 | */ |
||
40 | 110 | public function __construct(Context $context, LoaderInterface $loader) |
|
45 | |||
46 | /** |
||
47 | * @return LoaderInterface |
||
48 | */ |
||
49 | 9 | public function getLoader() |
|
53 | |||
54 | /** |
||
55 | * @return Context |
||
56 | */ |
||
57 | 1 | public function getContext() |
|
61 | |||
62 | /** |
||
63 | * @return array |
||
64 | */ |
||
65 | 19 | public function getTokenParsers() |
|
72 | |||
73 | /** |
||
74 | * @return array |
||
75 | */ |
||
76 | 19 | public function getFilters() |
|
77 | { |
||
78 | return [ |
||
79 | new \Twig_SimpleFilter('start', function ($node, $value) { |
||
80 | $node['_collection_type_filters']['start'] = $value; |
||
81 | |||
82 | return $node; |
||
83 | 19 | }, ['needs_context' => false]), |
|
84 | new \Twig_SimpleFilter('limit', function ($node, $value) { |
||
85 | $node['_collection_type_filters']['limit'] = $value; |
||
86 | |||
87 | return $node; |
||
88 | 19 | }, ['needs_context' => false]), |
|
89 | 19 | new \Twig_SimpleFilter('order', function ($node, $value1, $value2) { |
|
90 | $node['_collection_type_filters']['order'] = [$value1, $value2]; |
||
91 | |||
92 | return $node; |
||
93 | 19 | }, ['needs_context' => false]), |
|
94 | new \Twig_SimpleFilter('dateRange', function ($node, $value1, $value2) { |
||
95 | $node['_collection_type_filters']['date_range'] = [$value1, $value2]; |
||
96 | |||
97 | return $node; |
||
98 | }, ['needs_context' => false]), |
||
99 | ]; |
||
100 | 26 | } |
|
101 | |||
102 | 26 | /** |
|
103 | * @return array |
||
104 | */ |
||
105 | public function getGlobals() |
||
109 | |||
110 | 109 | /** |
|
111 | * @return string |
||
112 | */ |
||
113 | public function getName() |
||
117 | } |
||
118 |