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