Completed
Push — middleware-wip ( c84623...8fd059 )
by Romain
02:52
created

EntryNotFoundException::formRequestDataNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
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\Field\Activation\AbstractActivation;
17
use Romm\Formz\Configuration\Form\Form;
18
use Romm\Formz\Configuration\View\Classes\ViewClass;
19
use Romm\Formz\Configuration\View\Layouts\LayoutGroup;
20
use Romm\Formz\Configuration\View\View;
21
use Romm\Formz\Form\FormObject;
22
use Romm\Formz\Form\FormObjectRequestData;
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 ACTIVATION_CONDITION_NOT_FOUND = 'No condition "%s" was found.';
35
36
    const CONFIGURATION_FIELD_NOT_FOUND = 'The field "%s" was not found. Please use the function `%s::hasField()` before.';
37
38
    const VALIDATION_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidation()` before.';
39
40
    const VIEW_LAYOUT_NOT_FOUND = 'The layout "%s" was not found. Please use the function `%s::hasLayout()` before.';
41
42
    const VIEW_LAYOUT_ITEM_NOT_FOUND = 'The layout item "%s" was not found. Please use the function `%s::hasItem()` before.';
43
44
    const VIEW_CLASS_NOT_FOUND = 'The class "%s" was not found. Please use the function `%s::hasItem()` before.';
45
46
    const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".';
47
48
    const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".';
49
50
    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.';
51
52
    const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.';
53
54
    const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".';
55
56
    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.';
57
58
    const SLOT_NOT_FOUND = 'No slot "%s" was found.';
59
60
    const ARGUMENT_NOT_FOUND = 'Trying to get an argument that does not exist: "%s". Please use function `has()`.';
61
62
    const FORM_REQUEST_DATA_NOT_FOUND = 'The data "%s" was not found. Please use the function `%s::hasData()` before.';
63
64
    /**
65
     * @code 1472650209
66
     *
67
     * @param string $name
68
     * @param array  $list
69
     * @return self
70
     */
71
    final public static function conditionNotFound($name, array $list)
72
    {
73
        /** @var self $exception */
74
        $exception = self::getNewExceptionInstance(
75
            self::CONDITION_NOT_FOUND,
76
            [
77
                $name,
78
                implode('" ,"', array_keys($list))
79
            ]
80
        );
81
82
        return $exception;
83
    }
84
85
    /**
86
     * @code 1488482191
87
     *
88
     * @param string $name
89
     * @return self
90
     */
91
    final public static function activationConditionNotFound($name)
92
    {
93
        /** @var self $exception */
94
        $exception = self::getNewExceptionInstance(
95
            self::ACTIVATION_CONDITION_NOT_FOUND,
96
            [$name]
97
        );
98
99
        return $exception;
100
    }
101
102
    /**
103
     * @code 1489765133
104
     *
105
     * @param string $name
106
     * @return self
107
     */
108
    final public static function configurationFieldNotFound($name)
109
    {
110
        /** @var self $exception */
111
        $exception = self::getNewExceptionInstance(
112
            self::CONFIGURATION_FIELD_NOT_FOUND,
113
            [$name, Form::class]
114
        );
115
116
        return $exception;
117
    }
118
119
    /**
120
     * @code 1487672276
121
     *
122
     * @param string $name
123
     * @return self
124
     */
125
    final public static function validationNotFound($name)
126
    {
127
        /** @var self $exception */
128
        $exception = self::getNewExceptionInstance(
129
            self::VALIDATION_NOT_FOUND,
130
            [$name, AbstractActivation::class]
131
        );
132
133
        return $exception;
134
    }
135
136
    /**
137
     * @code 1489753952
138
     *
139
     * @param string $name
140
     * @return self
141
     */
142
    final public static function viewLayoutNotFound($name)
143
    {
144
        /** @var self $exception */
145
        $exception = self::getNewExceptionInstance(
146
            self::VIEW_LAYOUT_NOT_FOUND,
147
            [$name, View::class]
148
        );
149
150
        return $exception;
151
    }
152
153
    /**
154
     * @code 1489757511
155
     *
156
     * @param string $name
157
     * @return self
158
     */
159
    final public static function viewLayoutItemNotFound($name)
160
    {
161
        /** @var self $exception */
162
        $exception = self::getNewExceptionInstance(
163
            self::VIEW_LAYOUT_ITEM_NOT_FOUND,
164
            [$name, LayoutGroup::class]
165
        );
166
167
        return $exception;
168
    }
169
170
    /**
171
     * @code 1489754909
172
     *
173
     * @param string $name
174
     * @return self
175
     */
176
    final public static function viewClassNotFound($name)
177
    {
178
        /** @var self $exception */
179
        $exception = self::getNewExceptionInstance(
180
            self::VIEW_CLASS_NOT_FOUND,
181
            [$name, ViewClass::class]
182
        );
183
184
        return $exception;
185
    }
186
187
    /**
188
     * @code 1487672956
189
     *
190
     * @param string $validationName
191
     * @param string $fieldName
192
     * @return self
193
     */
194
    final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName)
195
    {
196
        /** @var self $exception */
197
        $exception = self::getNewExceptionInstance(
198
            self::VALIDATION_NOT_FOUND_FOR_FIELD,
199
            [$fieldName, $validationName]
200
        );
201
202
        return $exception;
203
    }
204
205
    /**
206
     * @code 1487671603
207
     *
208
     * @param string     $fieldName
209
     * @param FormObject $formObject
210
     * @return self
211
     */
212
    final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject)
213
    {
214
        /** @var self $exception */
215
        $exception = self::getNewExceptionInstance(
216
            self::FIELD_NOT_FOUND,
217
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
218
        );
219
220
        return $exception;
221
    }
222
223
    /**
224
     * @code 1455272659
225
     *
226
     * @param string            $key
227
     * @param AbstractValidator $validator
228
     * @return self
229
     */
230
    final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator)
231
    {
232
        /** @var self $exception */
233
        $exception = self::getNewExceptionInstance(
234
            self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR,
235
            [$key, get_class($validator)]
236
        );
237
238
        return $exception;
239
    }
240
241
    /**
242
     * @code 1487947224
243
     *
244
     * @param string     $fieldName
245
     * @param FormObject $formObject
246
     * @return self
247
     */
248
    final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject)
249
    {
250
        /** @var self $exception */
251
        $exception = self::getNewExceptionInstance(
252
            self::FIELD_NOT_FOUND,
253
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
254
        );
255
256
        return $exception;
257
    }
258
259
    /**
260
     * @code 1467623761
261
     *
262
     * @param string $fieldName
263
     * @return self
264
     */
265
    final public static function classViewHelperFieldNotFound($fieldName)
266
    {
267
        /** @var self $exception */
268
        $exception = self::getNewExceptionInstance(
269
            self::VIEW_HELPER_FIELD_NOT_FOUND,
270
            [$fieldName, ClassViewHelper::class, FieldViewHelper::class]
271
        );
272
273
        return $exception;
274
    }
275
276
    /**
277
     * @code 1467624152
278
     *
279
     * @param string $fieldName
280
     * @return self
281
     */
282
    final public static function formatMessageViewHelperFieldNotFound($fieldName)
283
    {
284
        /** @var self $exception */
285
        $exception = self::getNewExceptionInstance(
286
            self::VIEW_HELPER_FIELD_NOT_FOUND,
287
            [$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class]
288
        );
289
290
        return $exception;
291
    }
292
293
    /**
294
     * @code 1465243586
295
     *
296
     * @param string $layoutName
297
     * @return self
298
     */
299
    final public static function fieldViewHelperLayoutNotFound($layoutName)
300
    {
301
        /** @var self $exception */
302
        $exception = self::getNewExceptionInstance(
303
            self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND,
304
            [$layoutName]
305
        );
306
307
        return $exception;
308
    }
309
310
    /**
311
     * @code 1485867803
312
     *
313
     * @param string $layoutName
314
     * @param string $itemName
315
     * @return self
316
     */
317
    final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName)
318
    {
319
        /** @var self $exception */
320
        $exception = self::getNewExceptionInstance(
321
            self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND,
322
            [$layoutName, $itemName]
323
        );
324
325
        return $exception;
326
    }
327
328
    /**
329
     * @code 1473084335
330
     *
331
     * @param string     $fieldName
332
     * @param FormObject $formObject
333
     * @return self
334
     */
335
    final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject)
336
    {
337
        /** @var self $exception */
338
        $exception = self::getNewExceptionInstance(
339
            self::FIELD_NOT_FOUND,
340
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
341
        );
342
343
        return $exception;
344
    }
345
346
    /**
347
     * @code 1457441846
348
     *
349
     * @param string $controllerObjectName
350
     * @param string $actionName
351
     * @param string $formName
352
     * @return self
353
     */
354
    final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName)
355
    {
356
        /** @var self $exception */
357
        $exception = self::getNewExceptionInstance(
358
            self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING,
359
            [$controllerObjectName, $actionName . 'Action', $formName]
360
        );
361
362
        return $exception;
363
    }
364
365
    /**
366
     * @code 1488988452
367
     *
368
     * @param string $name
369
     * @return self
370
     */
371
    final public static function slotClosureSlotNotFound($name)
372
    {
373
        /** @var self $exception */
374
        $exception = self::getNewExceptionInstance(
375
            self::SLOT_NOT_FOUND,
376
            [$name]
377
        );
378
379
        return $exception;
380
    }
381
382
    /**
383
     * @code 1489497046
384
     *
385
     * @param string $name
386
     * @return self
387
     */
388
    final public static function slotArgumentsSlotNotFound($name)
389
    {
390
        /** @var self $exception */
391
        $exception = self::getNewExceptionInstance(
392
            self::SLOT_NOT_FOUND,
393
            [$name]
394
        );
395
396
        return $exception;
397
    }
398
399
    /**
400
     * @code 1490792697
401
     *
402
     * @param string $name
403
     * @return self
404
     */
405
    final public static function argumentNotFound($name)
406
    {
407
        /** @var self $exception */
408
        $exception = self::getNewExceptionInstance(
409
            self::ARGUMENT_NOT_FOUND,
410
            [$name]
411
        );
412
413
        return $exception;
414
    }
415
416
    /**
417
     * @code 1490799273
418
     *
419
     * @param string $name
420
     * @return self
421
     */
422
    final public static function formRequestDataNotFound($name)
423
    {
424
        /** @var self $exception */
425
        $exception = self::getNewExceptionInstance(
426
            self::FORM_REQUEST_DATA_NOT_FOUND,
427
            [$name, FormObjectRequestData::class]
428
        );
429
430
        return $exception;
431
    }
432
}
433