1 | <?php |
||
43 | class AjaxValidationController extends ActionController |
||
44 | { |
||
45 | const DEFAULT_ERROR_MESSAGE_KEY = 'default_error_message'; |
||
46 | |||
47 | /** |
||
48 | * @var Request |
||
49 | */ |
||
50 | protected $request; |
||
51 | |||
52 | /** |
||
53 | * @var Response |
||
54 | */ |
||
55 | protected $response; |
||
56 | |||
57 | /** |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $protectedRequestMode = true; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $formClassName; |
||
66 | |||
67 | /** |
||
68 | * @var string |
||
69 | */ |
||
70 | protected $formName; |
||
71 | |||
72 | /** |
||
73 | * @var string |
||
74 | */ |
||
75 | protected $fieldName; |
||
76 | |||
77 | /** |
||
78 | * @var string |
||
79 | */ |
||
80 | protected $validatorName; |
||
81 | |||
82 | /** |
||
83 | * @var FormInterface |
||
84 | */ |
||
85 | protected $form; |
||
86 | |||
87 | /** |
||
88 | * @var FormObject |
||
89 | */ |
||
90 | protected $formObject; |
||
91 | |||
92 | /** |
||
93 | * @var AjaxResult |
||
94 | */ |
||
95 | protected $result; |
||
96 | |||
97 | /** |
||
98 | * @var Validation |
||
99 | */ |
||
100 | protected $validation; |
||
101 | |||
102 | /** |
||
103 | * The only accepted method for the request is `POST`. |
||
104 | */ |
||
105 | public function initializeAction() |
||
111 | |||
112 | /** |
||
113 | * Will process the request, but also prevent any external message to be |
||
114 | * displayed, and catch any exception that could occur during the |
||
115 | * validation. |
||
116 | * |
||
117 | * @param RequestInterface $request |
||
118 | * @param ResponseInterface $response |
||
119 | * @throws Exception |
||
120 | */ |
||
121 | public function processRequest(RequestInterface $request, ResponseInterface $response) |
||
148 | |||
149 | /** |
||
150 | * Will take care of adding a new argument to the request, based on the form |
||
151 | * name and the form class name found in the request arguments. |
||
152 | */ |
||
153 | protected function initializeActionMethodValidators() |
||
179 | |||
180 | /** |
||
181 | * Main action that will process the field validation. |
||
182 | * |
||
183 | * @param string $name |
||
184 | * @param string $className |
||
185 | * @param string $fieldName |
||
186 | * @param string $validatorName |
||
187 | */ |
||
188 | public function runAction($name, $className, $fieldName, $validatorName) |
||
215 | |||
216 | /** |
||
217 | * @return Validation |
||
218 | * @throws EntryNotFoundException |
||
219 | * @throws InvalidConfigurationException |
||
220 | */ |
||
221 | protected function getFieldValidation() |
||
249 | |||
250 | /** |
||
251 | * Fetches errors/warnings/notices in the result, and put them in the JSON |
||
252 | * response. |
||
253 | */ |
||
254 | protected function injectResultInResponse() |
||
274 | |||
275 | /** |
||
276 | * @param array $result |
||
277 | */ |
||
278 | protected function setUpResponseResult(array $result) |
||
285 | |||
286 | /** |
||
287 | * @param FormzMessageInterface[] $messages |
||
288 | * @return array |
||
289 | */ |
||
290 | protected function formatMessages(array $messages) |
||
300 | |||
301 | /** |
||
302 | * Wrapper for unit tests. |
||
303 | * |
||
304 | * @param RequestInterface $request |
||
305 | * @param ResponseInterface $response |
||
306 | */ |
||
307 | protected function processRequestParent(RequestInterface $request, ResponseInterface $response) |
||
311 | |||
312 | /** |
||
313 | * Wrapper for unit tests. |
||
314 | */ |
||
315 | protected function initializeActionMethodValidatorsParent() |
||
319 | |||
320 | /** |
||
321 | * Used in unit testing. |
||
322 | * |
||
323 | * @param bool $flag |
||
324 | */ |
||
325 | public function setProtectedRequestMode($flag) |
||
329 | |||
330 | /** |
||
331 | * @param Exception $exception |
||
332 | * @return string |
||
333 | */ |
||
334 | protected function getDebugMessageForException(Exception $exception) |
||
338 | |||
339 | /** |
||
340 | * @return FormInterface |
||
341 | * @throws MissingArgumentException |
||
342 | */ |
||
343 | protected function getForm() |
||
347 | |||
348 | /** |
||
349 | * @return FormObject |
||
350 | */ |
||
351 | protected function getFormObject() |
||
358 | |||
359 | /** |
||
360 | * Wrapper for unit tests. |
||
361 | * |
||
362 | * @return Request |
||
363 | */ |
||
364 | protected function getRequest() |
||
368 | } |
||
369 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.