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\Form\Condition\Activation\AbstractActivation; |
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\FormObject; |
21
|
|
|
use Romm\Formz\Validation\Validator\AbstractValidator; |
22
|
|
|
use Romm\Formz\ViewHelpers\ClassViewHelper; |
23
|
|
|
use Romm\Formz\ViewHelpers\FieldViewHelper; |
24
|
|
|
use Romm\Formz\ViewHelpers\FormatMessageViewHelper; |
25
|
|
|
|
26
|
|
|
class EntryNotFoundException extends FormzException |
27
|
|
|
{ |
28
|
|
|
const FIELD_NOT_FOUND = 'The field "%s" was not found in the form "%s" with class "%s".'; |
29
|
|
|
|
30
|
|
|
const CONDITION_NOT_FOUND = 'No condition "%s" was found.'; |
31
|
|
|
|
32
|
|
|
const VALIDATION_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidation()` before.'; |
33
|
|
|
|
34
|
|
|
const VIEW_LAYOUT_NOT_FOUND = 'The layout "%s" was not found. Please use the function `%s::hasLayout()` before.'; |
35
|
|
|
|
36
|
|
|
const VIEW_LAYOUT_ITEM_NOT_FOUND = 'The layout item "%s" was not found. Please use the function `%s::hasItem()` before.'; |
37
|
|
|
|
38
|
|
|
const VIEW_CLASS_NOT_FOUND = 'The class "%s" was not found. Please use the function `%s::hasItem()` before.'; |
39
|
|
|
|
40
|
|
|
const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".'; |
41
|
|
|
|
42
|
|
|
const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".'; |
43
|
|
|
|
44
|
|
|
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.'; |
45
|
|
|
|
46
|
|
|
const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.'; |
47
|
|
|
|
48
|
|
|
const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".'; |
49
|
|
|
|
50
|
|
|
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.'; |
51
|
|
|
|
52
|
|
|
const SLOT_NOT_FOUND = 'No slot "%s" was found.'; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @code 1488482191 |
56
|
|
|
* |
57
|
|
|
* @param string $name |
58
|
|
|
* @return self |
59
|
|
|
*/ |
60
|
|
|
final public static function conditionNotFound($name) |
61
|
|
|
{ |
62
|
|
|
/** @var self $exception */ |
63
|
|
|
$exception = self::getNewExceptionInstance( |
64
|
|
|
self::CONDITION_NOT_FOUND, |
65
|
|
|
[$name] |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
return $exception; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @code 1487672276 |
73
|
|
|
* |
74
|
|
|
* @param string $name |
75
|
|
|
* @return self |
76
|
|
|
*/ |
77
|
|
|
final public static function validationNotFound($name) |
78
|
|
|
{ |
79
|
|
|
/** @var self $exception */ |
80
|
|
|
$exception = self::getNewExceptionInstance( |
81
|
|
|
self::VALIDATION_NOT_FOUND, |
82
|
|
|
[$name, AbstractActivation::class] |
83
|
|
|
); |
84
|
|
|
|
85
|
|
|
return $exception; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @code 1489753952 |
90
|
|
|
* |
91
|
|
|
* @param string $name |
92
|
|
|
* @return self |
93
|
|
|
*/ |
94
|
|
|
final public static function viewLayoutNotFound($name) |
95
|
|
|
{ |
96
|
|
|
/** @var self $exception */ |
97
|
|
|
$exception = self::getNewExceptionInstance( |
98
|
|
|
self::VIEW_LAYOUT_NOT_FOUND, |
99
|
|
|
[$name, View::class] |
100
|
|
|
); |
101
|
|
|
|
102
|
|
|
return $exception; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @code 1489757511 |
107
|
|
|
* |
108
|
|
|
* @param string $name |
109
|
|
|
* @return self |
110
|
|
|
*/ |
111
|
|
|
final public static function viewLayoutItemNotFound($name) |
112
|
|
|
{ |
113
|
|
|
/** @var self $exception */ |
114
|
|
|
$exception = self::getNewExceptionInstance( |
115
|
|
|
self::VIEW_LAYOUT_ITEM_NOT_FOUND, |
116
|
|
|
[$name, LayoutGroup::class] |
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
return $exception; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @code 1489754909 |
124
|
|
|
* |
125
|
|
|
* @param string $name |
126
|
|
|
* @return self |
127
|
|
|
*/ |
128
|
|
|
final public static function viewClassNotFound($name) |
129
|
|
|
{ |
130
|
|
|
/** @var self $exception */ |
131
|
|
|
$exception = self::getNewExceptionInstance( |
132
|
|
|
self::VIEW_CLASS_NOT_FOUND, |
133
|
|
|
[$name, ViewClass::class] |
134
|
|
|
); |
135
|
|
|
|
136
|
|
|
return $exception; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @code 1487672956 |
141
|
|
|
* |
142
|
|
|
* @param string $validationName |
143
|
|
|
* @param string $fieldName |
144
|
|
|
* @return EntryNotFoundException |
145
|
|
|
*/ |
146
|
|
|
final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName) |
147
|
|
|
{ |
148
|
|
|
/** @var self $exception */ |
149
|
|
|
$exception = self::getNewExceptionInstance( |
150
|
|
|
self::VALIDATION_NOT_FOUND_FOR_FIELD, |
151
|
|
|
[$fieldName, $validationName] |
152
|
|
|
); |
153
|
|
|
|
154
|
|
|
return $exception; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @code 1487671603 |
159
|
|
|
* |
160
|
|
|
* @param string $fieldName |
161
|
|
|
* @param FormObject $formObject |
162
|
|
|
* @return EntryNotFoundException |
163
|
|
|
*/ |
164
|
|
|
final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject) |
165
|
|
|
{ |
166
|
|
|
/** @var self $exception */ |
167
|
|
|
$exception = self::getNewExceptionInstance( |
168
|
|
|
self::FIELD_NOT_FOUND, |
169
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
170
|
|
|
); |
171
|
|
|
|
172
|
|
|
return $exception; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @code 1455272659 |
177
|
|
|
* |
178
|
|
|
* @param string $key |
179
|
|
|
* @param AbstractValidator $validator |
180
|
|
|
* @return EntryNotFoundException |
181
|
|
|
*/ |
182
|
|
|
final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator) |
183
|
|
|
{ |
184
|
|
|
/** @var self $exception */ |
185
|
|
|
$exception = self::getNewExceptionInstance( |
186
|
|
|
self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR, |
187
|
|
|
[$key, get_class($validator)] |
188
|
|
|
); |
189
|
|
|
|
190
|
|
|
return $exception; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @code 1487947224 |
195
|
|
|
* |
196
|
|
|
* @param string $fieldName |
197
|
|
|
* @param FormObject $formObject |
198
|
|
|
* @return EntryNotFoundException |
199
|
|
|
*/ |
200
|
|
|
final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject) |
201
|
|
|
{ |
202
|
|
|
/** @var self $exception */ |
203
|
|
|
$exception = self::getNewExceptionInstance( |
204
|
|
|
self::FIELD_NOT_FOUND, |
205
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
206
|
|
|
); |
207
|
|
|
|
208
|
|
|
return $exception; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @code 1467623761 |
213
|
|
|
* |
214
|
|
|
* @param string $fieldName |
215
|
|
|
* @return self |
216
|
|
|
*/ |
217
|
|
|
final public static function classViewHelperFieldNotFound($fieldName) |
218
|
|
|
{ |
219
|
|
|
/** @var self $exception */ |
220
|
|
|
$exception = self::getNewExceptionInstance( |
221
|
|
|
self::VIEW_HELPER_FIELD_NOT_FOUND, |
222
|
|
|
[$fieldName, ClassViewHelper::class, FieldViewHelper::class] |
223
|
|
|
); |
224
|
|
|
|
225
|
|
|
return $exception; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @code 1467624152 |
230
|
|
|
* |
231
|
|
|
* @param string $fieldName |
232
|
|
|
* @return self |
233
|
|
|
*/ |
234
|
|
|
final public static function formatMessageViewHelperFieldNotFound($fieldName) |
235
|
|
|
{ |
236
|
|
|
/** @var self $exception */ |
237
|
|
|
$exception = self::getNewExceptionInstance( |
238
|
|
|
self::VIEW_HELPER_FIELD_NOT_FOUND, |
239
|
|
|
[$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class] |
240
|
|
|
); |
241
|
|
|
|
242
|
|
|
return $exception; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* @code 1465243586 |
247
|
|
|
* |
248
|
|
|
* @param string $layoutName |
249
|
|
|
* @return self |
250
|
|
|
*/ |
251
|
|
|
final public static function fieldViewHelperLayoutNotFound($layoutName) |
252
|
|
|
{ |
253
|
|
|
/** @var self $exception */ |
254
|
|
|
$exception = self::getNewExceptionInstance( |
255
|
|
|
self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND, |
256
|
|
|
[$layoutName] |
257
|
|
|
); |
258
|
|
|
|
259
|
|
|
return $exception; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @code 1485867803 |
264
|
|
|
* |
265
|
|
|
* @param string $layoutName |
266
|
|
|
* @param string $itemName |
267
|
|
|
* @return EntryNotFoundException |
268
|
|
|
*/ |
269
|
|
|
final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName) |
270
|
|
|
{ |
271
|
|
|
/** @var self $exception */ |
272
|
|
|
$exception = self::getNewExceptionInstance( |
273
|
|
|
self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND, |
274
|
|
|
[$layoutName, $itemName] |
275
|
|
|
); |
276
|
|
|
|
277
|
|
|
return $exception; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @code 1473084335 |
282
|
|
|
* |
283
|
|
|
* @param string $fieldName |
284
|
|
|
* @param FormObject $formObject |
285
|
|
|
* @return EntryNotFoundException |
286
|
|
|
*/ |
287
|
|
|
final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject) |
288
|
|
|
{ |
289
|
|
|
/** @var self $exception */ |
290
|
|
|
$exception = self::getNewExceptionInstance( |
291
|
|
|
self::FIELD_NOT_FOUND, |
292
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
293
|
|
|
); |
294
|
|
|
|
295
|
|
|
return $exception; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* @code 1457441846 |
300
|
|
|
* |
301
|
|
|
* @param string $controllerObjectName |
302
|
|
|
* @param string $actionName |
303
|
|
|
* @param string $formName |
304
|
|
|
* @return EntryNotFoundException |
305
|
|
|
*/ |
306
|
|
|
final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName) |
307
|
|
|
{ |
308
|
|
|
/** @var self $exception */ |
309
|
|
|
$exception = self::getNewExceptionInstance( |
310
|
|
|
self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING, |
311
|
|
|
[$controllerObjectName, $actionName . 'Action', $formName] |
312
|
|
|
); |
313
|
|
|
|
314
|
|
|
return $exception; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @code 1488988452 |
319
|
|
|
* |
320
|
|
|
* @param string $name |
321
|
|
|
* @return self |
322
|
|
|
*/ |
323
|
|
|
final public static function slotClosureSlotNotFound($name) |
324
|
|
|
{ |
325
|
|
|
/** @var self $exception */ |
326
|
|
|
$exception = self::getNewExceptionInstance( |
327
|
|
|
self::SLOT_NOT_FOUND, |
328
|
|
|
[$name] |
329
|
|
|
); |
330
|
|
|
|
331
|
|
|
return $exception; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @code 1489497046 |
336
|
|
|
* |
337
|
|
|
* @param string $name |
338
|
|
|
* @return self |
339
|
|
|
*/ |
340
|
|
|
final public static function slotArgumentsSlotNotFound($name) |
341
|
|
|
{ |
342
|
|
|
/** @var self $exception */ |
343
|
|
|
$exception = self::getNewExceptionInstance( |
344
|
|
|
self::SLOT_NOT_FOUND, |
345
|
|
|
[$name] |
346
|
|
|
); |
347
|
|
|
|
348
|
|
|
return $exception; |
349
|
|
|
} |
350
|
|
|
} |
351
|
|
|
|