1 | <?php |
||
9 | class PjaxExtension extends \Twig_Extension |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @var PjaxHelperInterface |
||
14 | */ |
||
15 | protected $pjax; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $sections = []; |
||
21 | |||
22 | /** |
||
23 | * @var RequestStack |
||
24 | */ |
||
25 | protected $requestStack; |
||
26 | |||
27 | /** |
||
28 | * @param PjaxHelperInterface $pjax |
||
29 | * @param RequestStack $requestStack |
||
30 | */ |
||
31 | public function __construct(PjaxHelperInterface $pjax, RequestStack $requestStack) |
||
36 | |||
37 | /** |
||
38 | * {@inheritDoc} |
||
39 | */ |
||
40 | public function getFunctions() |
||
51 | |||
52 | /** |
||
53 | * {@inheritDoc} |
||
54 | */ |
||
55 | public function getFilters() |
||
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | public function getLayout($section = 'default', $layout = null) |
||
84 | |||
85 | /** |
||
86 | * @param string $section |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getBase($section = 'default') |
||
102 | |||
103 | /** |
||
104 | * @param array $sections |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function setSections(array $sections) |
||
114 | |||
115 | /** |
||
116 | * @param Request $request |
||
117 | * |
||
118 | * @return string|null |
||
119 | */ |
||
120 | public function pjaxVersion(Request $request) |
||
126 | |||
127 | /** |
||
128 | * Convert array to html attributes |
||
129 | * |
||
130 | * @param array $attributes |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function toAttributes(array $attributes = array()) |
||
151 | |||
152 | /** |
||
153 | * Has Request been made by PJAX? |
||
154 | * |
||
155 | * @param Request $request |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | public function isPjax(Request $request) |
||
163 | |||
164 | /** |
||
165 | * @param Request $request |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getPjaxTarget(Request $request) |
||
173 | |||
174 | /** |
||
175 | * Generate PJAX attributes |
||
176 | * |
||
177 | * @param string $target data-pjax-container="$target" where content will load |
||
178 | * @param string $redirectTarget data-pjax-redirect-target="$redirectTarget" where content will load after redirect |
||
179 | * |
||
180 | * @return array |
||
181 | */ |
||
182 | public function generatePjaxAttributes($target = null, $redirectTarget = null) |
||
194 | |||
195 | /** |
||
196 | * {@inheritDoc} |
||
197 | */ |
||
198 | public function getName() |
||
202 | |||
203 | /** |
||
204 | * @param string $section |
||
205 | * |
||
206 | * @return array |
||
207 | */ |
||
208 | protected function getSectionConfig($section) |
||
217 | } |
||
218 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: