1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* 2017 Romain CANON <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
7
|
|
|
* under the terms of the GNU General Public License, either |
8
|
|
|
* version 3 of the License, or any later version. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, see: |
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Romm\Formz\Exceptions; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Configuration\Configuration; |
17
|
|
|
use Romm\Formz\Configuration\View\Classes\ViewClass; |
18
|
|
|
use Romm\Formz\Configuration\View\Layouts\LayoutGroup; |
19
|
|
|
use Romm\Formz\Configuration\View\View; |
20
|
|
|
use Romm\Formz\Form\Definition\Field\Activation\AbstractActivation; |
21
|
|
|
use Romm\Formz\Form\Definition\FormDefinition; |
22
|
|
|
use Romm\Formz\Form\FormObject\FormObject; |
23
|
|
|
use Romm\Formz\Validation\Validator\AbstractValidator; |
24
|
|
|
use Romm\Formz\ViewHelpers\ClassViewHelper; |
25
|
|
|
use Romm\Formz\ViewHelpers\FieldViewHelper; |
26
|
|
|
use Romm\Formz\ViewHelpers\FormatMessageViewHelper; |
27
|
|
|
|
28
|
|
|
class EntryNotFoundException extends FormzException |
29
|
|
|
{ |
30
|
|
|
const FIELD_NOT_FOUND = 'The field "%s" was not found in the form "%s" with class "%s".'; |
31
|
|
|
|
32
|
|
|
const CONDITION_NOT_FOUND = 'Trying to access a condition which is not registered: "%s". Here is a list of all currently registered conditions: "%s".'; |
33
|
|
|
|
34
|
|
|
const ADD_CONDITION_NOT_FOUND = 'Trying to add a condition "%s" which is not registered to the form definition. Here is a list of all currently registered conditions: "%s".'; |
35
|
|
|
|
36
|
|
|
const INSTANTIATE_CONDITION_NOT_FOUND = 'Trying to instantiate a condition which is not registered: "%s". Here is a list of all currently registered conditions: "%s".'; |
37
|
|
|
|
38
|
|
|
const ACTIVATION_CONDITION_NOT_FOUND = 'No condition "%s" was found.'; |
39
|
|
|
|
40
|
|
|
const CONFIGURATION_FIELD_NOT_FOUND = 'The field "%s" was not found. Please use the function `%s::hasField()` before.'; |
41
|
|
|
|
42
|
|
|
const VALIDATOR_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidator()` before.'; |
43
|
|
|
|
44
|
|
|
const VIEW_LAYOUT_NOT_FOUND = 'The layout "%s" was not found. Please use the function `%s::hasLayout()` before.'; |
45
|
|
|
|
46
|
|
|
const VIEW_LAYOUT_ITEM_NOT_FOUND = 'The layout item "%s" was not found. Please use the function `%s::hasItem()` before.'; |
47
|
|
|
|
48
|
|
|
const VIEW_CLASS_NOT_FOUND = 'The class "%s" was not found. Please use the function `%s::hasItem()` before.'; |
49
|
|
|
|
50
|
|
|
const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".'; |
51
|
|
|
|
52
|
|
|
const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".'; |
53
|
|
|
|
54
|
|
|
const VIEW_HELPER_FIELD_NOT_FOUND = 'The field "%s" could not be fetched for the view helper "%s": please either use this view helper inside the view helper "%s", or fill the parameter `field` of this view helper with the field name you want.'; |
55
|
|
|
|
56
|
|
|
const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.'; |
57
|
|
|
|
58
|
|
|
const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".'; |
59
|
|
|
|
60
|
|
|
const CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING = 'The method `%s::%s()` must have a parameter `$%s`. Note that you can also change the parameter `name` of the form view helper.'; |
61
|
|
|
|
62
|
|
|
const SLOT_NOT_FOUND = 'No slot "%s" was found.'; |
63
|
|
|
|
64
|
|
|
const FORM_CONFIGURATION_NOT_FOUND = 'The configuration for form of class "%s" was not found. Please use the function `%s::hasForm()` before.'; |
65
|
|
|
|
66
|
|
|
const CONDITION_NOT_FOUND_IN_DEFINITION = 'The condition "%s" was not found in the form definition. Please use the function `%s::hasCondition()` before.'; |
67
|
|
|
|
68
|
|
|
const CONDITION_DOES_NOT_EXIST = 'The condition "%s" does not exist'; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @code 1472650209 |
72
|
|
|
* |
73
|
|
|
* @param string $identifier |
74
|
|
|
* @param array $list |
75
|
|
|
* @return self |
76
|
|
|
*/ |
77
|
|
|
final public static function conditionNotFound($identifier, array $list) |
78
|
|
|
{ |
79
|
|
|
/** @var self $exception */ |
80
|
|
|
$exception = self::getNewExceptionInstance( |
81
|
|
|
self::CONDITION_NOT_FOUND, |
82
|
|
|
[ |
83
|
|
|
$identifier, |
84
|
|
|
implode('" ,"', array_keys($list)) |
85
|
|
|
] |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
return $exception; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @code 1493890438 |
93
|
|
|
* |
94
|
|
|
* @param string $identifier |
95
|
|
|
* @param array $list |
96
|
|
|
* @return self |
97
|
|
|
*/ |
98
|
|
|
final public static function addConditionNotFound($identifier, array $list) |
99
|
|
|
{ |
100
|
|
|
/** @var self $exception */ |
101
|
|
|
$exception = self::getNewExceptionInstance( |
102
|
|
|
self::ADD_CONDITION_NOT_FOUND, |
103
|
|
|
[ |
104
|
|
|
$identifier, |
105
|
|
|
implode('" ,"', array_keys($list)) |
106
|
|
|
] |
107
|
|
|
); |
108
|
|
|
|
109
|
|
|
return $exception; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @code 1493890825 |
114
|
|
|
* |
115
|
|
|
* @param string $identifier |
116
|
|
|
* @param array $list |
117
|
|
|
* @return self |
118
|
|
|
*/ |
119
|
|
|
final public static function instantiateConditionNotFound($identifier, array $list) |
120
|
|
|
{ |
121
|
|
|
/** @var self $exception */ |
122
|
|
|
$exception = self::getNewExceptionInstance( |
123
|
|
|
self::INSTANTIATE_CONDITION_NOT_FOUND, |
124
|
|
|
[ |
125
|
|
|
$identifier, |
126
|
|
|
implode('" ,"', array_keys($list)) |
127
|
|
|
] |
128
|
|
|
); |
129
|
|
|
|
130
|
|
|
return $exception; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @code 1488482191 |
135
|
|
|
* |
136
|
|
|
* @param string $name |
137
|
|
|
* @return self |
138
|
|
|
*/ |
139
|
|
|
final public static function activationConditionNotFound($name) |
140
|
|
|
{ |
141
|
|
|
/** @var self $exception */ |
142
|
|
|
$exception = self::getNewExceptionInstance( |
143
|
|
|
self::ACTIVATION_CONDITION_NOT_FOUND, |
144
|
|
|
[$name] |
145
|
|
|
); |
146
|
|
|
|
147
|
|
|
return $exception; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @code 1489765133 |
152
|
|
|
* |
153
|
|
|
* @param string $name |
154
|
|
|
* @return self |
155
|
|
|
*/ |
156
|
|
|
final public static function configurationFieldNotFound($name) |
157
|
|
|
{ |
158
|
|
|
/** @var self $exception */ |
159
|
|
|
$exception = self::getNewExceptionInstance( |
160
|
|
|
self::CONFIGURATION_FIELD_NOT_FOUND, |
161
|
|
|
[$name, FormDefinition::class] |
162
|
|
|
); |
163
|
|
|
|
164
|
|
|
return $exception; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @code 1487672276 |
169
|
|
|
* |
170
|
|
|
* @param string $name |
171
|
|
|
* @return self |
172
|
|
|
*/ |
173
|
|
|
final public static function validatorNotFound($name) |
174
|
|
|
{ |
175
|
|
|
/** @var self $exception */ |
176
|
|
|
$exception = self::getNewExceptionInstance( |
177
|
|
|
self::VALIDATOR_NOT_FOUND, |
178
|
|
|
[$name, AbstractActivation::class] |
179
|
|
|
); |
180
|
|
|
|
181
|
|
|
return $exception; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @code 1489753952 |
186
|
|
|
* |
187
|
|
|
* @param string $name |
188
|
|
|
* @return self |
189
|
|
|
*/ |
190
|
|
|
final public static function viewLayoutNotFound($name) |
191
|
|
|
{ |
192
|
|
|
/** @var self $exception */ |
193
|
|
|
$exception = self::getNewExceptionInstance( |
194
|
|
|
self::VIEW_LAYOUT_NOT_FOUND, |
195
|
|
|
[$name, View::class] |
196
|
|
|
); |
197
|
|
|
|
198
|
|
|
return $exception; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @code 1489757511 |
203
|
|
|
* |
204
|
|
|
* @param string $name |
205
|
|
|
* @return self |
206
|
|
|
*/ |
207
|
|
|
final public static function viewLayoutItemNotFound($name) |
208
|
|
|
{ |
209
|
|
|
/** @var self $exception */ |
210
|
|
|
$exception = self::getNewExceptionInstance( |
211
|
|
|
self::VIEW_LAYOUT_ITEM_NOT_FOUND, |
212
|
|
|
[$name, LayoutGroup::class] |
213
|
|
|
); |
214
|
|
|
|
215
|
|
|
return $exception; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @code 1489754909 |
220
|
|
|
* |
221
|
|
|
* @param string $name |
222
|
|
|
* @return self |
223
|
|
|
*/ |
224
|
|
|
final public static function viewClassNotFound($name) |
225
|
|
|
{ |
226
|
|
|
/** @var self $exception */ |
227
|
|
|
$exception = self::getNewExceptionInstance( |
228
|
|
|
self::VIEW_CLASS_NOT_FOUND, |
229
|
|
|
[$name, ViewClass::class] |
230
|
|
|
); |
231
|
|
|
|
232
|
|
|
return $exception; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @code 1487672956 |
237
|
|
|
* |
238
|
|
|
* @param string $validationName |
239
|
|
|
* @param string $fieldName |
240
|
|
|
* @return self |
241
|
|
|
*/ |
242
|
|
|
final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName) |
243
|
|
|
{ |
244
|
|
|
/** @var self $exception */ |
245
|
|
|
$exception = self::getNewExceptionInstance( |
246
|
|
|
self::VALIDATION_NOT_FOUND_FOR_FIELD, |
247
|
|
|
[$fieldName, $validationName] |
248
|
|
|
); |
249
|
|
|
|
250
|
|
|
return $exception; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @code 1487671603 |
255
|
|
|
* |
256
|
|
|
* @param string $fieldName |
257
|
|
|
* @param FormObject $formObject |
258
|
|
|
* @return self |
259
|
|
|
*/ |
260
|
|
|
final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject) |
261
|
|
|
{ |
262
|
|
|
/** @var self $exception */ |
263
|
|
|
$exception = self::getNewExceptionInstance( |
264
|
|
|
self::FIELD_NOT_FOUND, |
265
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
266
|
|
|
); |
267
|
|
|
|
268
|
|
|
return $exception; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* @code 1455272659 |
273
|
|
|
* |
274
|
|
|
* @param string $key |
275
|
|
|
* @param AbstractValidator $validator |
276
|
|
|
* @return self |
277
|
|
|
*/ |
278
|
|
|
final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator) |
279
|
|
|
{ |
280
|
|
|
/** @var self $exception */ |
281
|
|
|
$exception = self::getNewExceptionInstance( |
282
|
|
|
self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR, |
283
|
|
|
[$key, get_class($validator)] |
284
|
|
|
); |
285
|
|
|
|
286
|
|
|
return $exception; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* @code 1487947224 |
291
|
|
|
* |
292
|
|
|
* @param string $fieldName |
293
|
|
|
* @param FormObject $formObject |
294
|
|
|
* @return self |
295
|
|
|
*/ |
296
|
|
|
final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject) |
297
|
|
|
{ |
298
|
|
|
/** @var self $exception */ |
299
|
|
|
$exception = self::getNewExceptionInstance( |
300
|
|
|
self::FIELD_NOT_FOUND, |
301
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
302
|
|
|
); |
303
|
|
|
|
304
|
|
|
return $exception; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @code 1467623761 |
309
|
|
|
* |
310
|
|
|
* @param string $fieldName |
311
|
|
|
* @return self |
312
|
|
|
*/ |
313
|
|
|
final public static function classViewHelperFieldNotFound($fieldName) |
314
|
|
|
{ |
315
|
|
|
/** @var self $exception */ |
316
|
|
|
$exception = self::getNewExceptionInstance( |
317
|
|
|
self::VIEW_HELPER_FIELD_NOT_FOUND, |
318
|
|
|
[$fieldName, ClassViewHelper::class, FieldViewHelper::class] |
319
|
|
|
); |
320
|
|
|
|
321
|
|
|
return $exception; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* @code 1467624152 |
326
|
|
|
* |
327
|
|
|
* @param string $fieldName |
328
|
|
|
* @return self |
329
|
|
|
*/ |
330
|
|
|
final public static function formatMessageViewHelperFieldNotFound($fieldName) |
331
|
|
|
{ |
332
|
|
|
/** @var self $exception */ |
333
|
|
|
$exception = self::getNewExceptionInstance( |
334
|
|
|
self::VIEW_HELPER_FIELD_NOT_FOUND, |
335
|
|
|
[$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class] |
336
|
|
|
); |
337
|
|
|
|
338
|
|
|
return $exception; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* @code 1465243586 |
343
|
|
|
* |
344
|
|
|
* @param string $layoutName |
345
|
|
|
* @return self |
346
|
|
|
*/ |
347
|
|
|
final public static function fieldViewHelperLayoutNotFound($layoutName) |
348
|
|
|
{ |
349
|
|
|
/** @var self $exception */ |
350
|
|
|
$exception = self::getNewExceptionInstance( |
351
|
|
|
self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND, |
352
|
|
|
[$layoutName] |
353
|
|
|
); |
354
|
|
|
|
355
|
|
|
return $exception; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* @code 1485867803 |
360
|
|
|
* |
361
|
|
|
* @param string $layoutName |
362
|
|
|
* @param string $itemName |
363
|
|
|
* @return self |
364
|
|
|
*/ |
365
|
|
|
final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName) |
366
|
|
|
{ |
367
|
|
|
/** @var self $exception */ |
368
|
|
|
$exception = self::getNewExceptionInstance( |
369
|
|
|
self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND, |
370
|
|
|
[$layoutName, $itemName] |
371
|
|
|
); |
372
|
|
|
|
373
|
|
|
return $exception; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* @code 1473084335 |
378
|
|
|
* |
379
|
|
|
* @param string $fieldName |
380
|
|
|
* @param FormObject $formObject |
381
|
|
|
* @return self |
382
|
|
|
*/ |
383
|
|
|
final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject) |
384
|
|
|
{ |
385
|
|
|
/** @var self $exception */ |
386
|
|
|
$exception = self::getNewExceptionInstance( |
387
|
|
|
self::FIELD_NOT_FOUND, |
388
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
389
|
|
|
); |
390
|
|
|
|
391
|
|
|
return $exception; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* @code 1457441846 |
396
|
|
|
* |
397
|
|
|
* @param string $controllerObjectName |
398
|
|
|
* @param string $actionName |
399
|
|
|
* @param string $formName |
400
|
|
|
* @return self |
401
|
|
|
*/ |
402
|
|
|
final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName) |
403
|
|
|
{ |
404
|
|
|
/** @var self $exception */ |
405
|
|
|
$exception = self::getNewExceptionInstance( |
406
|
|
|
self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING, |
407
|
|
|
[$controllerObjectName, $actionName . 'Action', $formName] |
408
|
|
|
); |
409
|
|
|
|
410
|
|
|
return $exception; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* @code 1488988452 |
415
|
|
|
* |
416
|
|
|
* @param string $name |
417
|
|
|
* @return self |
418
|
|
|
*/ |
419
|
|
|
final public static function slotClosureSlotNotFound($name) |
420
|
|
|
{ |
421
|
|
|
/** @var self $exception */ |
422
|
|
|
$exception = self::getNewExceptionInstance( |
423
|
|
|
self::SLOT_NOT_FOUND, |
424
|
|
|
[$name] |
425
|
|
|
); |
426
|
|
|
|
427
|
|
|
return $exception; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* @code 1489497046 |
432
|
|
|
* |
433
|
|
|
* @param string $name |
434
|
|
|
* @return self |
435
|
|
|
*/ |
436
|
|
|
final public static function slotArgumentsSlotNotFound($name) |
437
|
|
|
{ |
438
|
|
|
/** @var self $exception */ |
439
|
|
|
$exception = self::getNewExceptionInstance( |
440
|
|
|
self::SLOT_NOT_FOUND, |
441
|
|
|
[$name] |
442
|
|
|
); |
443
|
|
|
|
444
|
|
|
return $exception; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* @code 1491997168 |
449
|
|
|
* |
450
|
|
|
* @return self |
451
|
|
|
*/ |
452
|
|
|
final public static function formConfigurationNotFound() |
453
|
|
|
{ |
454
|
|
|
/** @var self $exception */ |
455
|
|
|
$exception = self::getNewExceptionInstance( |
456
|
|
|
self::FORM_CONFIGURATION_NOT_FOUND, |
457
|
|
|
[Configuration::class] |
458
|
|
|
); |
459
|
|
|
|
460
|
|
|
return $exception; |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
/** |
464
|
|
|
* @code 1493881671 |
465
|
|
|
* |
466
|
|
|
* @param string $name |
467
|
|
|
* @return self |
468
|
|
|
*/ |
469
|
|
|
final public static function conditionNotFoundInDefinition($name) |
470
|
|
|
{ |
471
|
|
|
/** @var self $exception */ |
472
|
|
|
$exception = self::getNewExceptionInstance( |
473
|
|
|
self::CONDITION_NOT_FOUND_IN_DEFINITION, |
474
|
|
|
[$name, Configuration::class] |
475
|
|
|
); |
476
|
|
|
|
477
|
|
|
return $exception; |
478
|
|
|
} |
479
|
|
|
} |
480
|
|
|
|