Completed
Push — middleware-wip ( aa44a7...fcef97 )
by Romain
03:00
created

formConfigurationNotFound()   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 0
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\Form\Field\Activation\AbstractActivation;
18
use Romm\Formz\Configuration\Form\Form;
19
use Romm\Formz\Configuration\Form\Step\Step;
20
use Romm\Formz\Configuration\View\Classes\ViewClass;
21
use Romm\Formz\Configuration\View\Layouts\LayoutGroup;
22
use Romm\Formz\Configuration\View\View;
23
use Romm\Formz\Domain\Model\DataObject\FormMetadataObject;
24
use Romm\Formz\Domain\Model\FormMetadata;
25
use Romm\Formz\Form\FormObject\FormObject;
26
use Romm\Formz\Form\FormObject\Service\FormObjectRequestData;
27
use Romm\Formz\Persistence\Item\Session\SessionPersistence;
28
use Romm\Formz\Validation\Validator\AbstractValidator;
29
use Romm\Formz\ViewHelpers\ClassViewHelper;
30
use Romm\Formz\ViewHelpers\FieldViewHelper;
31
use Romm\Formz\ViewHelpers\FormatMessageViewHelper;
32
33
class EntryNotFoundException extends FormzException
34
{
35
    const FIELD_NOT_FOUND = 'The field "%s" was not found in the form "%s" with class "%s".';
36
37
    const CONDITION_NOT_FOUND = 'Trying to access a condition which is not registered: "%s". Here is a list of all currently registered conditions: "%s".';
38
39
    const ACTIVATION_CONDITION_NOT_FOUND = 'No condition "%s" was found.';
40
41
    const CONFIGURATION_FIELD_NOT_FOUND = 'The field "%s" was not found. Please use the function `%s::hasField()` before.';
42
43
    const VALIDATION_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidation()` before.';
44
45
    const VIEW_LAYOUT_NOT_FOUND = 'The layout "%s" was not found. Please use the function `%s::hasLayout()` before.';
46
47
    const VIEW_LAYOUT_ITEM_NOT_FOUND = 'The layout item "%s" was not found. Please use the function `%s::hasItem()` before.';
48
49
    const VIEW_CLASS_NOT_FOUND = 'The class "%s" was not found. Please use the function `%s::hasItem()` before.';
50
51
    const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".';
52
53
    const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".';
54
55
    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.';
56
57
    const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.';
58
59
    const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".';
60
61
    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.';
62
63
    const SLOT_NOT_FOUND = 'No slot "%s" was found.';
64
65
    const ARGUMENT_NOT_FOUND = 'Trying to get an argument that does not exist: "%s". Please use function `has()`.';
66
67
    const FORM_REQUEST_DATA_NOT_FOUND = 'The data "%s" was not found. Please use the function `%s::hasData()` before.';
68
69
    const PERSISTENCE_SESSION_ENTRY_NOT_FOUND = 'The form with identifier "%s" was not found in the session, please use the function `%s::has()` before.';
70
71
    const META_DATA_NOT_FOUND = 'The metadata "%s" was not found. Please use the function `%s::has()` before.';
72
73
    const FORM_CONFIGURATION_NOT_FOUND = 'The configuration for form of class "%s" was not found. Please use the function `%s::hasForm()` before.';
74
75
    const MIDDLEWARE_NOT_FOUND = 'The middleware "%s" was not found. Please use the function `%s::hasMiddleware()` before.';
76
77
    const STEP_ITEM_NOT_FOUND = 'The step "%s" does not exist. Please use the function `%s::hasStep()` before.';
78
79
    /**
80
     * @code 1472650209
81
     *
82
     * @param string $name
83
     * @param array  $list
84
     * @return self
85
     */
86
    final public static function conditionNotFound($name, array $list)
87
    {
88
        /** @var self $exception */
89
        $exception = self::getNewExceptionInstance(
90
            self::CONDITION_NOT_FOUND,
91
            [
92
                $name,
93
                implode('" ,"', array_keys($list))
94
            ]
95
        );
96
97
        return $exception;
98
    }
99
100
    /**
101
     * @code 1488482191
102
     *
103
     * @param string $name
104
     * @return self
105
     */
106
    final public static function activationConditionNotFound($name)
107
    {
108
        /** @var self $exception */
109
        $exception = self::getNewExceptionInstance(
110
            self::ACTIVATION_CONDITION_NOT_FOUND,
111
            [$name]
112
        );
113
114
        return $exception;
115
    }
116
117
    /**
118
     * @code 1489765133
119
     *
120
     * @param string $name
121
     * @return self
122
     */
123
    final public static function configurationFieldNotFound($name)
124
    {
125
        /** @var self $exception */
126
        $exception = self::getNewExceptionInstance(
127
            self::CONFIGURATION_FIELD_NOT_FOUND,
128
            [$name, Form::class]
129
        );
130
131
        return $exception;
132
    }
133
134
    /**
135
     * @code 1487672276
136
     *
137
     * @param string $name
138
     * @return self
139
     */
140
    final public static function validationNotFound($name)
141
    {
142
        /** @var self $exception */
143
        $exception = self::getNewExceptionInstance(
144
            self::VALIDATION_NOT_FOUND,
145
            [$name, AbstractActivation::class]
146
        );
147
148
        return $exception;
149
    }
150
151
    /**
152
     * @code 1489753952
153
     *
154
     * @param string $name
155
     * @return self
156
     */
157
    final public static function viewLayoutNotFound($name)
158
    {
159
        /** @var self $exception */
160
        $exception = self::getNewExceptionInstance(
161
            self::VIEW_LAYOUT_NOT_FOUND,
162
            [$name, View::class]
163
        );
164
165
        return $exception;
166
    }
167
168
    /**
169
     * @code 1489757511
170
     *
171
     * @param string $name
172
     * @return self
173
     */
174
    final public static function viewLayoutItemNotFound($name)
175
    {
176
        /** @var self $exception */
177
        $exception = self::getNewExceptionInstance(
178
            self::VIEW_LAYOUT_ITEM_NOT_FOUND,
179
            [$name, LayoutGroup::class]
180
        );
181
182
        return $exception;
183
    }
184
185
    /**
186
     * @code 1489754909
187
     *
188
     * @param string $name
189
     * @return self
190
     */
191
    final public static function viewClassNotFound($name)
192
    {
193
        /** @var self $exception */
194
        $exception = self::getNewExceptionInstance(
195
            self::VIEW_CLASS_NOT_FOUND,
196
            [$name, ViewClass::class]
197
        );
198
199
        return $exception;
200
    }
201
202
    /**
203
     * @code 1487672956
204
     *
205
     * @param string $validationName
206
     * @param string $fieldName
207
     * @return self
208
     */
209
    final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName)
210
    {
211
        /** @var self $exception */
212
        $exception = self::getNewExceptionInstance(
213
            self::VALIDATION_NOT_FOUND_FOR_FIELD,
214
            [$fieldName, $validationName]
215
        );
216
217
        return $exception;
218
    }
219
220
    /**
221
     * @code 1487671603
222
     *
223
     * @param string     $fieldName
224
     * @param FormObject $formObject
225
     * @return self
226
     */
227
    final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject)
228
    {
229
        /** @var self $exception */
230
        $exception = self::getNewExceptionInstance(
231
            self::FIELD_NOT_FOUND,
232
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
233
        );
234
235
        return $exception;
236
    }
237
238
    /**
239
     * @code 1455272659
240
     *
241
     * @param string            $key
242
     * @param AbstractValidator $validator
243
     * @return self
244
     */
245
    final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator)
246
    {
247
        /** @var self $exception */
248
        $exception = self::getNewExceptionInstance(
249
            self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR,
250
            [$key, get_class($validator)]
251
        );
252
253
        return $exception;
254
    }
255
256
    /**
257
     * @code 1487947224
258
     *
259
     * @param string     $fieldName
260
     * @param FormObject $formObject
261
     * @return self
262
     */
263
    final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject)
264
    {
265
        /** @var self $exception */
266
        $exception = self::getNewExceptionInstance(
267
            self::FIELD_NOT_FOUND,
268
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
269
        );
270
271
        return $exception;
272
    }
273
274
    /**
275
     * @code 1467623761
276
     *
277
     * @param string $fieldName
278
     * @return self
279
     */
280
    final public static function classViewHelperFieldNotFound($fieldName)
281
    {
282
        /** @var self $exception */
283
        $exception = self::getNewExceptionInstance(
284
            self::VIEW_HELPER_FIELD_NOT_FOUND,
285
            [$fieldName, ClassViewHelper::class, FieldViewHelper::class]
286
        );
287
288
        return $exception;
289
    }
290
291
    /**
292
     * @code 1467624152
293
     *
294
     * @param string $fieldName
295
     * @return self
296
     */
297
    final public static function formatMessageViewHelperFieldNotFound($fieldName)
298
    {
299
        /** @var self $exception */
300
        $exception = self::getNewExceptionInstance(
301
            self::VIEW_HELPER_FIELD_NOT_FOUND,
302
            [$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class]
303
        );
304
305
        return $exception;
306
    }
307
308
    /**
309
     * @code 1465243586
310
     *
311
     * @param string $layoutName
312
     * @return self
313
     */
314
    final public static function fieldViewHelperLayoutNotFound($layoutName)
315
    {
316
        /** @var self $exception */
317
        $exception = self::getNewExceptionInstance(
318
            self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND,
319
            [$layoutName]
320
        );
321
322
        return $exception;
323
    }
324
325
    /**
326
     * @code 1485867803
327
     *
328
     * @param string $layoutName
329
     * @param string $itemName
330
     * @return self
331
     */
332
    final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName)
333
    {
334
        /** @var self $exception */
335
        $exception = self::getNewExceptionInstance(
336
            self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND,
337
            [$layoutName, $itemName]
338
        );
339
340
        return $exception;
341
    }
342
343
    /**
344
     * @code 1473084335
345
     *
346
     * @param string     $fieldName
347
     * @param FormObject $formObject
348
     * @return self
349
     */
350
    final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject)
351
    {
352
        /** @var self $exception */
353
        $exception = self::getNewExceptionInstance(
354
            self::FIELD_NOT_FOUND,
355
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
356
        );
357
358
        return $exception;
359
    }
360
361
    /**
362
     * @code 1457441846
363
     *
364
     * @param string $controllerObjectName
365
     * @param string $actionName
366
     * @param string $formName
367
     * @return self
368
     */
369
    final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName)
370
    {
371
        /** @var self $exception */
372
        $exception = self::getNewExceptionInstance(
373
            self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING,
374
            [$controllerObjectName, $actionName . 'Action', $formName]
375
        );
376
377
        return $exception;
378
    }
379
380
    /**
381
     * @code 1488988452
382
     *
383
     * @param string $name
384
     * @return self
385
     */
386
    final public static function slotClosureSlotNotFound($name)
387
    {
388
        /** @var self $exception */
389
        $exception = self::getNewExceptionInstance(
390
            self::SLOT_NOT_FOUND,
391
            [$name]
392
        );
393
394
        return $exception;
395
    }
396
397
    /**
398
     * @code 1489497046
399
     *
400
     * @param string $name
401
     * @return self
402
     */
403
    final public static function slotArgumentsSlotNotFound($name)
404
    {
405
        /** @var self $exception */
406
        $exception = self::getNewExceptionInstance(
407
            self::SLOT_NOT_FOUND,
408
            [$name]
409
        );
410
411
        return $exception;
412
    }
413
414
    /**
415
     * @code 1490792697
416
     *
417
     * @param string $name
418
     * @return self
419
     */
420
    final public static function argumentNotFound($name)
421
    {
422
        /** @var self $exception */
423
        $exception = self::getNewExceptionInstance(
424
            self::ARGUMENT_NOT_FOUND,
425
            [$name]
426
        );
427
428
        return $exception;
429
    }
430
431
    /**
432
     * @code 1490799273
433
     *
434
     * @param string $name
435
     * @return self
436
     */
437
    final public static function formRequestDataNotFound($name)
438
    {
439
        /** @var self $exception */
440
        $exception = self::getNewExceptionInstance(
441
            self::FORM_REQUEST_DATA_NOT_FOUND,
442
            [$name, FormObjectRequestData::class]
443
        );
444
445
        return $exception;
446
    }
447
448
    /**
449
     * @code 1491293933
450
     *
451
     * @param FormMetadata $metadata
452
     * @return self
453
     */
454
    final public static function persistenceSessionEntryNotFound(FormMetadata $metadata)
455
    {
456
        /** @var self $exception */
457
        $exception = self::getNewExceptionInstance(
458
            self::PERSISTENCE_SESSION_ENTRY_NOT_FOUND,
459
            [$metadata->getHash(), SessionPersistence::class]
460
        );
461
462
        return $exception;
463
    }
464
465
    /**
466
     * @code 1491814768
467
     *
468
     * @param string $key
469
     * @return self
470
     */
471
    final public static function metadataNotFound($key)
472
    {
473
        /** @var self $exception */
474
        $exception = self::getNewExceptionInstance(
475
            self::META_DATA_NOT_FOUND,
476
            [$key, FormMetadataObject::class]
477
        );
478
479
        return $exception;
480
    }
481
482
    /**
483
     * @code 1491997168
484
     *
485
     * @return self
486
     */
487
    final public static function formConfigurationNotFound()
488
    {
489
        /** @var self $exception */
490
        $exception = self::getNewExceptionInstance(
491
            self::FORM_CONFIGURATION_NOT_FOUND,
492
            [Configuration::class]
493
        );
494
495
        return $exception;
496
    }
497
498
    /**
499
     * @code 1491997309
500
     *
501
     * @param string $name
502
     * @return self
503
     */
504
    final public static function middlewareNotFound($name)
505
    {
506
        /** @var self $exception */
507
        $exception = self::getNewExceptionInstance(
508
            self::MIDDLEWARE_NOT_FOUND,
509
            [$name, Form::class]
510
        );
511
512
        return $exception;
513
    }
514
515
    /**
516
     * @code 1491997577
517
     *
518
     * @param string $name
519
     * @return self
520
     */
521
    final public static function stepItemNotFound($name)
522
    {
523
        /** @var self $exception */
524
        $exception = self::getNewExceptionInstance(
525
            self::STEP_ITEM_NOT_FOUND,
526
            [$name, Step::class]
527
        );
528
529
        return $exception;
530
    }
531
}
532