1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* 2016 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\Form\FormObject; |
18
|
|
|
use Romm\Formz\Validation\Validator\AbstractValidator; |
19
|
|
|
use Romm\Formz\ViewHelpers\ClassViewHelper; |
20
|
|
|
use Romm\Formz\ViewHelpers\FieldViewHelper; |
21
|
|
|
use Romm\Formz\ViewHelpers\FormatMessageViewHelper; |
22
|
|
|
|
23
|
|
|
class EntryNotFoundException extends FormzException |
24
|
|
|
{ |
25
|
|
|
const FIELD_NOT_FOUND = 'The field "%s" was not found in the form "%s" with class "%s".'; |
26
|
|
|
|
27
|
|
|
const CONDITION_NOT_FOUND = 'No condition "%s" was found.'; |
28
|
|
|
|
29
|
|
|
const VALIDATION_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidation()` before.'; |
30
|
|
|
|
31
|
|
|
const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".'; |
32
|
|
|
|
33
|
|
|
const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".'; |
34
|
|
|
|
35
|
|
|
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.'; |
36
|
|
|
|
37
|
|
|
const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.'; |
38
|
|
|
|
39
|
|
|
const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".'; |
40
|
|
|
|
41
|
|
|
const FORM_VIEW_HELPER_CONTROLLER_ACTION_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.'; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @code 1488482191 |
45
|
|
|
* |
46
|
|
|
* @param string $name |
47
|
|
|
* @return self |
48
|
|
|
*/ |
49
|
|
|
final public static function conditionNotFound($name) |
50
|
|
|
{ |
51
|
|
|
/** @var self $exception */ |
52
|
|
|
$exception = self::getNewExceptionInstance( |
53
|
|
|
self::CONDITION_NOT_FOUND, |
54
|
|
|
[$name] |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
return $exception; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @code 1487672276 |
62
|
|
|
* |
63
|
|
|
* @param string $name |
64
|
|
|
* @return self |
65
|
|
|
*/ |
66
|
|
|
final public static function validationNotFound($name) |
67
|
|
|
{ |
68
|
|
|
/** @var self $exception */ |
69
|
|
|
$exception = self::getNewExceptionInstance( |
70
|
|
|
self::VALIDATION_NOT_FOUND, |
71
|
|
|
[$name, AbstractActivation::class] |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
return $exception; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @code 1487672956 |
79
|
|
|
* |
80
|
|
|
* @param string $validationName |
81
|
|
|
* @param string $fieldName |
82
|
|
|
* @return EntryNotFoundException |
83
|
|
|
*/ |
84
|
|
|
final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName) |
85
|
|
|
{ |
86
|
|
|
/** @var self $exception */ |
87
|
|
|
$exception = self::getNewExceptionInstance( |
88
|
|
|
self::VALIDATION_NOT_FOUND_FOR_FIELD, |
89
|
|
|
[$fieldName, $validationName] |
90
|
|
|
); |
91
|
|
|
|
92
|
|
|
return $exception; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @code 1487671603 |
97
|
|
|
* |
98
|
|
|
* @param string $fieldName |
99
|
|
|
* @param FormObject $formObject |
100
|
|
|
* @return EntryNotFoundException |
101
|
|
|
*/ |
102
|
|
|
final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject) |
103
|
|
|
{ |
104
|
|
|
/** @var self $exception */ |
105
|
|
|
$exception = self::getNewExceptionInstance( |
106
|
|
|
self::FIELD_NOT_FOUND, |
107
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
108
|
|
|
); |
109
|
|
|
|
110
|
|
|
return $exception; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @code 1455272659 |
115
|
|
|
* |
116
|
|
|
* @param string $key |
117
|
|
|
* @param AbstractValidator $validator |
118
|
|
|
* @return EntryNotFoundException |
119
|
|
|
*/ |
120
|
|
|
final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator) |
121
|
|
|
{ |
122
|
|
|
/** @var self $exception */ |
123
|
|
|
$exception = self::getNewExceptionInstance( |
124
|
|
|
self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR, |
125
|
|
|
[$key, get_class($validator)] |
126
|
|
|
); |
127
|
|
|
|
128
|
|
|
return $exception; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @code 1487947224 |
133
|
|
|
* |
134
|
|
|
* @param string $fieldName |
135
|
|
|
* @param FormObject $formObject |
136
|
|
|
* @return EntryNotFoundException |
137
|
|
|
*/ |
138
|
|
|
final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject) |
139
|
|
|
{ |
140
|
|
|
/** @var self $exception */ |
141
|
|
|
$exception = self::getNewExceptionInstance( |
142
|
|
|
self::FIELD_NOT_FOUND, |
143
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
144
|
|
|
); |
145
|
|
|
|
146
|
|
|
return $exception; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @code 1467623761 |
151
|
|
|
* |
152
|
|
|
* @param string $fieldName |
153
|
|
|
* @return self |
154
|
|
|
*/ |
155
|
|
|
final public static function classViewHelperFieldNotFound($fieldName) |
156
|
|
|
{ |
157
|
|
|
/** @var self $exception */ |
158
|
|
|
$exception = self::getNewExceptionInstance( |
159
|
|
|
self::VIEW_HELPER_FIELD_NOT_FOUND, |
160
|
|
|
[$fieldName, ClassViewHelper::class, FieldViewHelper::class] |
161
|
|
|
); |
162
|
|
|
|
163
|
|
|
return $exception; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @code 1467624152 |
168
|
|
|
* |
169
|
|
|
* @param string $fieldName |
170
|
|
|
* @return self |
171
|
|
|
*/ |
172
|
|
|
final public static function formatMessageViewHelperFieldNotFound($fieldName) |
173
|
|
|
{ |
174
|
|
|
/** @var self $exception */ |
175
|
|
|
$exception = self::getNewExceptionInstance( |
176
|
|
|
self::VIEW_HELPER_FIELD_NOT_FOUND, |
177
|
|
|
[$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class] |
178
|
|
|
); |
179
|
|
|
|
180
|
|
|
return $exception; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @code 1465243586 |
185
|
|
|
* |
186
|
|
|
* @param string $layoutName |
187
|
|
|
* @return self |
188
|
|
|
*/ |
189
|
|
|
final public static function fieldViewHelperLayoutNotFound($layoutName) |
190
|
|
|
{ |
191
|
|
|
/** @var self $exception */ |
192
|
|
|
$exception = self::getNewExceptionInstance( |
193
|
|
|
self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND, |
194
|
|
|
[$layoutName] |
195
|
|
|
); |
196
|
|
|
|
197
|
|
|
return $exception; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @code 1485867803 |
202
|
|
|
* |
203
|
|
|
* @param string $layoutName |
204
|
|
|
* @param string $itemName |
205
|
|
|
* @return EntryNotFoundException |
206
|
|
|
*/ |
207
|
|
|
final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName) |
208
|
|
|
{ |
209
|
|
|
/** @var self $exception */ |
210
|
|
|
$exception = self::getNewExceptionInstance( |
211
|
|
|
self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND, |
212
|
|
|
[$layoutName, $itemName] |
213
|
|
|
); |
214
|
|
|
|
215
|
|
|
return $exception; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @code 1473084335 |
220
|
|
|
* |
221
|
|
|
* @param string $fieldName |
222
|
|
|
* @param FormObject $formObject |
223
|
|
|
* @return EntryNotFoundException |
224
|
|
|
*/ |
225
|
|
|
final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject) |
226
|
|
|
{ |
227
|
|
|
/** @var self $exception */ |
228
|
|
|
$exception = self::getNewExceptionInstance( |
229
|
|
|
self::FIELD_NOT_FOUND, |
230
|
|
|
[$fieldName, $formObject->getName(), $formObject->getClassName()] |
231
|
|
|
); |
232
|
|
|
|
233
|
|
|
return $exception; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @code 1457441846 |
238
|
|
|
* |
239
|
|
|
* @param string $controllerObjectName |
240
|
|
|
* @param string $actionName |
241
|
|
|
* @param string $formName |
242
|
|
|
* @return EntryNotFoundException |
243
|
|
|
*/ |
244
|
|
|
final public static function formViewHelperControllerActionArgumentMissing($controllerObjectName, $actionName, $formName) |
245
|
|
|
{ |
246
|
|
|
/** @var self $exception */ |
247
|
|
|
$exception = self::getNewExceptionInstance( |
248
|
|
|
self::FORM_VIEW_HELPER_CONTROLLER_ACTION_ARGUMENT_MISSING, |
249
|
|
|
[$controllerObjectName, $actionName, $formName] |
250
|
|
|
); |
251
|
|
|
|
252
|
|
|
return $exception; |
253
|
|
|
} |
254
|
|
|
} |
255
|
|
|
|