1 | <?php |
||
50 | class AjaxValidationController extends ActionController |
||
51 | { |
||
52 | const DEFAULT_ERROR_MESSAGE_KEY = 'default_error_message'; |
||
53 | |||
54 | /** |
||
55 | * @var Request |
||
56 | */ |
||
57 | protected $request; |
||
58 | |||
59 | /** |
||
60 | * @var Response |
||
61 | */ |
||
62 | protected $response; |
||
63 | |||
64 | /** |
||
65 | * @var bool |
||
66 | */ |
||
67 | protected $protectedRequestMode = true; |
||
68 | |||
69 | /** |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $formClassName; |
||
73 | |||
74 | /** |
||
75 | * @var string |
||
76 | */ |
||
77 | protected $formName; |
||
78 | |||
79 | /** |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $fieldName; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | */ |
||
87 | protected $validatorName; |
||
88 | |||
89 | /** |
||
90 | * @var FormInterface |
||
91 | */ |
||
92 | protected $form; |
||
93 | |||
94 | /** |
||
95 | * @var FormObject |
||
96 | */ |
||
97 | protected $formObject; |
||
98 | |||
99 | /** |
||
100 | * @var AjaxResult |
||
101 | */ |
||
102 | protected $result; |
||
103 | |||
104 | /** |
||
105 | * @var Validator |
||
106 | */ |
||
107 | protected $validation; |
||
108 | |||
109 | /** |
||
110 | * The only accepted method for the request is `POST`. |
||
111 | */ |
||
112 | public function initializeAction() |
||
118 | |||
119 | /** |
||
120 | * Will process the request, but also prevent any external message to be |
||
121 | * displayed, and catch any exception that could occur during the |
||
122 | * validation. |
||
123 | * |
||
124 | * @param RequestInterface $request |
||
125 | * @param ResponseInterface $response |
||
126 | * @throws Exception |
||
127 | */ |
||
128 | public function processRequest(RequestInterface $request, ResponseInterface $response) |
||
155 | |||
156 | /** |
||
157 | * Will take care of adding a new argument to the request, based on the form |
||
158 | * name and the form class name found in the request arguments. |
||
159 | */ |
||
160 | protected function initializeActionMethodValidators() |
||
190 | |||
191 | /** |
||
192 | * Main action that will process the field validation. |
||
193 | * |
||
194 | * @param string $name |
||
195 | * @param string $className |
||
196 | * @param string $fieldName |
||
197 | * @param string $validatorName |
||
198 | * @param string $formzData |
||
199 | */ |
||
200 | public function runAction($name, $className, $fieldName, $validatorName, $formzData) |
||
232 | |||
233 | /** |
||
234 | * If an error occurs, that must be because the mapping of the arguments |
||
235 | * failed somehow. Therefore we override the default behaviour (forward to |
||
236 | * referring request) and we throw an exception instead. |
||
237 | * |
||
238 | * @throws InvalidArgumentValueException |
||
239 | */ |
||
240 | public function errorAction() |
||
244 | |||
245 | /** |
||
246 | * Will call all middlewares of the form. |
||
247 | * |
||
248 | * Note that the field validation scope is used, meaning some middlewares |
||
249 | * wont be called. |
||
250 | * |
||
251 | * @see \Romm\Formz\Middleware\Scope\FieldValidationScope |
||
252 | */ |
||
253 | protected function invokeMiddlewares() |
||
280 | |||
281 | /** |
||
282 | * Will fetch the settings of the content object that was used to render the |
||
283 | * form calling this controller. |
||
284 | * |
||
285 | * @return array |
||
286 | */ |
||
287 | protected function getContentObjectSettings() |
||
298 | |||
299 | /** |
||
300 | * @return Validator |
||
301 | * @throws EntryNotFoundException |
||
302 | * @throws InvalidConfigurationException |
||
303 | */ |
||
304 | protected function getFieldValidation() |
||
332 | |||
333 | /** |
||
334 | * Fetches errors/warnings/notices in the result, and put them in the JSON |
||
335 | * response. |
||
336 | */ |
||
337 | protected function injectResultInResponse() |
||
357 | |||
358 | /** |
||
359 | * @param array $result |
||
360 | */ |
||
361 | protected function setUpResponseResult(array $result) |
||
368 | |||
369 | /** |
||
370 | * @param FormzMessageInterface[] $messages |
||
371 | * @return array |
||
372 | */ |
||
373 | protected function formatMessages(array $messages) |
||
383 | |||
384 | /** |
||
385 | * Wrapper for unit tests. |
||
386 | * |
||
387 | * @param RequestInterface $request |
||
388 | * @param ResponseInterface $response |
||
389 | */ |
||
390 | protected function processRequestParent(RequestInterface $request, ResponseInterface $response) |
||
394 | |||
395 | /** |
||
396 | * Wrapper for unit tests. |
||
397 | */ |
||
398 | protected function initializeActionMethodValidatorsParent() |
||
402 | |||
403 | /** |
||
404 | * Used in unit testing. |
||
405 | * |
||
406 | * @param bool $flag |
||
407 | */ |
||
408 | public function setProtectedRequestMode($flag) |
||
412 | |||
413 | /** |
||
414 | * @param Exception $exception |
||
415 | * @return string |
||
416 | */ |
||
417 | protected function getDebugMessageForException(Exception $exception) |
||
421 | |||
422 | /** |
||
423 | * @return FormInterface |
||
424 | * @throws MissingArgumentException |
||
425 | */ |
||
426 | protected function getForm() |
||
433 | |||
434 | /** |
||
435 | * @return FormObject |
||
436 | */ |
||
437 | protected function getFormObject() |
||
441 | |||
442 | /** |
||
443 | * Wrapper for unit tests. |
||
444 | * |
||
445 | * @return Request |
||
446 | */ |
||
447 | protected function getRequest() |
||
451 | } |
||
452 |
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.