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