1 | <?php |
||
39 | class AjaxValidationController extends ActionController |
||
40 | { |
||
41 | const ARGUMENT_FORM_CLASS_NAME = 'formClassName'; |
||
42 | const ARGUMENT_FORM_NAME = 'formName'; |
||
43 | const ARGUMENT_FORM = 'form'; |
||
44 | const ARGUMENT_FIELD_NAME = 'fieldName'; |
||
45 | const ARGUMENT_VALIDATOR_NAME = 'validatorName'; |
||
46 | |||
47 | const DEFAULT_ERROR_MESSAGE_KEY = 'default_error_message'; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | public static $requiredArguments = [ |
||
53 | self::ARGUMENT_FORM_CLASS_NAME, |
||
54 | self::ARGUMENT_FORM_NAME, |
||
55 | self::ARGUMENT_FORM, |
||
56 | self::ARGUMENT_FIELD_NAME, |
||
57 | self::ARGUMENT_VALIDATOR_NAME |
||
58 | ]; |
||
59 | |||
60 | /** |
||
61 | * @var JsonView |
||
62 | */ |
||
63 | protected $view; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $defaultViewObjectName = JsonView::class; |
||
69 | |||
70 | /** |
||
71 | * @var Request |
||
72 | */ |
||
73 | protected $request; |
||
74 | |||
75 | /** |
||
76 | * @var bool |
||
77 | */ |
||
78 | protected $protectedRequestMode = true; |
||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $formClassName; |
||
84 | |||
85 | /** |
||
86 | * @var string |
||
87 | */ |
||
88 | protected $formName; |
||
89 | |||
90 | /** |
||
91 | * @var array |
||
92 | */ |
||
93 | protected $form; |
||
94 | |||
95 | /** |
||
96 | * @var string |
||
97 | */ |
||
98 | protected $fieldName; |
||
99 | |||
100 | /** |
||
101 | * @var string |
||
102 | */ |
||
103 | protected $validatorName; |
||
104 | |||
105 | /** |
||
106 | * @var FormObject |
||
107 | */ |
||
108 | protected $formObject; |
||
109 | |||
110 | /** |
||
111 | * The only accepted method for the request is `POST`. |
||
112 | */ |
||
113 | public function initializeAction() |
||
119 | |||
120 | public function getView() |
||
124 | |||
125 | /** |
||
126 | * Main action that will render the validation result. |
||
127 | */ |
||
128 | public function runAction() |
||
137 | |||
138 | /** |
||
139 | * @param bool $flag |
||
140 | */ |
||
141 | public function setProtectedRequestMode($flag) |
||
145 | |||
146 | /** |
||
147 | * Will fetch the result and prevent any exception or external message to be |
||
148 | * displayed. |
||
149 | * |
||
150 | * @return array |
||
151 | */ |
||
152 | protected function getProtectedRequestResult() |
||
179 | |||
180 | /** |
||
181 | * Will get the result of the validation for this Ajax request. |
||
182 | * |
||
183 | * If any error is found, an exception is thrown. |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | protected function getRequestResult() |
||
210 | |||
211 | /** |
||
212 | * Initializes all arguments for the request, and returns an array |
||
213 | * containing the missing arguments. |
||
214 | */ |
||
215 | protected function initializeArguments() |
||
236 | |||
237 | /** |
||
238 | * @return FormObject |
||
239 | */ |
||
240 | protected function getFormObject() |
||
247 | |||
248 | /** |
||
249 | * @throws InvalidConfigurationException |
||
250 | */ |
||
251 | protected function checkConfigurationValidationResult() |
||
262 | |||
263 | /** |
||
264 | * @return Validation |
||
265 | * @throws EntryNotFoundException |
||
266 | * @throws InvalidConfigurationException |
||
267 | */ |
||
268 | protected function getFieldValidation() |
||
291 | |||
292 | /** |
||
293 | * @param FormObject $formObject |
||
294 | * @return Form |
||
295 | * @throws EntryNotFoundException |
||
296 | */ |
||
297 | protected function getFormConfiguration(FormObject $formObject) |
||
310 | |||
311 | /** |
||
312 | * Will build and fill an object with a form sent value. |
||
313 | * |
||
314 | * @return FormInterface |
||
315 | */ |
||
316 | protected function buildFormObject() |
||
322 | |||
323 | /** |
||
324 | * Will convert the result of the function called by this class in a JSON |
||
325 | * string. |
||
326 | * |
||
327 | * @param Result $result |
||
328 | * @return array |
||
329 | */ |
||
330 | protected function convertResultToJson(Result $result) |
||
351 | |||
352 | /** |
||
353 | * @param FormzMessageInterface[] $messages |
||
354 | * @return array |
||
355 | */ |
||
356 | protected function formatMessages(array $messages) |
||
366 | |||
367 | /** |
||
368 | * @param \Exception $exception |
||
369 | * @return string |
||
370 | */ |
||
371 | protected function getDebugMessageForException(\Exception $exception) |
||
375 | |||
376 | /** |
||
377 | * @param string $name |
||
378 | * @return mixed |
||
379 | */ |
||
380 | protected function getArgument($name) |
||
384 | |||
385 | /** |
||
386 | * Will clean the string filled with form values sent with Ajax. |
||
387 | * |
||
388 | * @param array $values |
||
389 | * @return array |
||
390 | */ |
||
391 | protected function cleanValuesFromUrl($values) |
||
400 | |||
401 | /** |
||
402 | * @return PropertyMapper |
||
403 | */ |
||
404 | protected function getPropertyMapper() |
||
411 | } |
||
412 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: