Completed
Push — feature/middleware ( f1ca06...1ed36f )
by Romain
02:16
created

persistenceSessionEntryNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
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\Configuration;
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\Definition\Field\Field;
21
use Romm\Formz\Form\Definition\Field\Validation\Validator;
22
use Romm\Formz\Form\Definition\FormDefinition;
23
use Romm\Formz\Form\FormInterface;
24
use Romm\Formz\Form\FormObject\FormObject;
25
use Romm\Formz\Form\FormObject\FormObjectFactory;
26
use Romm\Formz\Form\FormObject\Service\FormObjectRequestData;
27
use Romm\Formz\Validation\Validator\AbstractValidator;
28
use Romm\Formz\ViewHelpers\ClassViewHelper;
29
use Romm\Formz\ViewHelpers\FieldViewHelper;
30
use Romm\Formz\ViewHelpers\FormatMessageViewHelper;
31
32
class EntryNotFoundException extends FormzException
33
{
34
    const FIELD_NOT_FOUND = 'The field "%s" was not found in the form "%s" with class "%s".';
35
36
    const CONDITION_NOT_FOUND = 'Trying to access a condition which is not registered: "%s". Here is a list of all currently registered conditions: "%s".';
37
38
    const FORM_ADD_CONDITION_NOT_FOUND = 'Trying to add a condition "%s" which is not registered to the form definition. Here is a list of all currently registered conditions: "%s".';
39
40
    const ACTIVATION_ADD_CONDITION_NOT_FOUND = 'Trying to add a condition "%s" which is not registered to the activation. Here is a list of all currently registered conditions: "%s".';
41
42
    const INSTANTIATE_CONDITION_NOT_FOUND = 'Trying to instantiate a condition which is not registered: "%s". Here is a list of all currently registered conditions: "%s".';
43
44
    const ACTIVATION_CONDITION_NOT_FOUND = 'No condition "%s" was found.';
45
46
    const CONFIGURATION_FIELD_NOT_FOUND = 'The field "%s" was not found. Please use the function `%s::hasField()` before.';
47
48
    const VALIDATOR_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidator()` before.';
49
50
    const BEHAVIOUR_NOT_FOUND = 'The behaviour "%s" was not found. Please use the function `%s::hasBehaviour()` before.';
51
52
    const MESSAGE_NOT_FOUND = 'The message "%s" was not found. Please use the function `%s::hasMessage()` before.';
53
54
    const VIEW_LAYOUT_NOT_FOUND = 'The layout "%s" was not found. Please use the function `%s::hasLayout()` before.';
55
56
    const VIEW_LAYOUT_ITEM_NOT_FOUND = 'The layout item "%s" was not found. Please use the function `%s::hasItem()` before.';
57
58
    const VIEW_CLASS_NOT_FOUND = 'The class "%s" was not found. Please use the function `%s::hasItem()` before.';
59
60
    const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".';
61
62
    const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".';
63
64
    const VIEW_HELPER_FIELD_NOT_FOUND = 'The field 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.';
65
66
    const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.';
67
68
    const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".';
69
70
    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.';
71
72
    const SLOT_NOT_FOUND = 'No slot "%s" was found.';
73
74
    const ARGUMENT_NOT_FOUND = 'Trying to get an argument that does not exist: "%s". Please use function `has()`.';
75
76
    const FORM_REQUEST_DATA_NOT_FOUND = 'The data "%s" was not found. Please use the function `%s::hasData()` before.';
77
78
    const PERSISTENCE_SESSION_ENTRY_NOT_FOUND = 'The form with identifier "%s" was not found in the session, please use the function `%s::has()` before.';
79
80
    const META_DATA_NOT_FOUND = 'The metadata "%s" was not found. Please use the function `%s::has()` before.';
81
82
    const FORM_CONFIGURATION_NOT_FOUND = 'The configuration for form of class "%s" was not found. Please use the function `%s::hasForm()` before.';
83
84
    const CONDITION_NOT_FOUND_IN_DEFINITION = 'The condition "%s" was not found in the form definition. Please use the function `%s::hasCondition()` before.';
85
86
    const CONDITION_DOES_NOT_EXIST = 'The condition "%s" does not exist';
87
88
    const MIDDLEWARE_NOT_FOUND = 'The middleware "%s" was not found. Please use the function `%s::hasMiddleware()` before.';
89
90
    const STEP_ENTRY_NOT_FOUND = 'The step "%s" was not found. Please use the function `%s::hasEntry()` before.';
91
92
    const NEXT_STEPS_NOT_FOUND = 'The step definition for the step "%s" does not have next steps. Please use the function `%s::hasNextSteps()` before.';
93
94
    const PREVIOUS_DEFINITION_NOT_FOUND = 'The step definition for the step "%s" does not have a previous definition. Please use the function `%s::hasPreviousDefinition()` before.';
95
96
    const FORM_OBJECT_INSTANCE_NOT_FOUND = 'The form instance for the object of type "%s" was not found. Please take care of registering it before with "%s::registerFormInstance()".';
97
98
    /**
99
     * @code 1472650209
100
     *
101
     * @param string $identifier
102
     * @param array  $list
103
     * @return self
104
     */
105
    final public static function conditionNotFound($identifier, array $list)
106
    {
107
        /** @var self $exception */
108
        $exception = self::getNewExceptionInstance(
109
            self::CONDITION_NOT_FOUND,
110
            [
111
                $identifier,
112
                implode('" ,"', array_keys($list))
113
            ]
114
        );
115
116
        return $exception;
117
    }
118
119
    /**
120
     * @code 1493890438
121
     *
122
     * @param string $identifier
123
     * @param array  $list
124
     * @return self
125
     */
126
    final public static function formAddConditionNotFound($identifier, array $list)
127
    {
128
        /** @var self $exception */
129
        $exception = self::getNewExceptionInstance(
130
            self::FORM_ADD_CONDITION_NOT_FOUND,
131
            [
132
                $identifier,
133
                implode('" ,"', array_keys($list))
134
            ]
135
        );
136
137
        return $exception;
138
    }
139
140
    /**
141
     * @code 1494329341
142
     *
143
     * @param string $identifier
144
     * @param array  $list
145
     * @return self
146
     */
147
    final public static function activationAddConditionNotFound($identifier, array $list)
148
    {
149
        /** @var self $exception */
150
        $exception = self::getNewExceptionInstance(
151
            self::ACTIVATION_ADD_CONDITION_NOT_FOUND,
152
            [
153
                $identifier,
154
                implode('" ,"', array_keys($list))
155
            ]
156
        );
157
158
        return $exception;
159
    }
160
161
    /**
162
     * @code 1493890825
163
     *
164
     * @param string $identifier
165
     * @param array  $list
166
     * @return self
167
     */
168
    final public static function instantiateConditionNotFound($identifier, array $list)
169
    {
170
        /** @var self $exception */
171
        $exception = self::getNewExceptionInstance(
172
            self::INSTANTIATE_CONDITION_NOT_FOUND,
173
            [
174
                $identifier,
175
                implode('" ,"', array_keys($list))
176
            ]
177
        );
178
179
        return $exception;
180
    }
181
182
    /**
183
     * @code 1488482191
184
     *
185
     * @param string $name
186
     * @return self
187
     */
188
    final public static function activationConditionNotFound($name)
189
    {
190
        /** @var self $exception */
191
        $exception = self::getNewExceptionInstance(
192
            self::ACTIVATION_CONDITION_NOT_FOUND,
193
            [$name]
194
        );
195
196
        return $exception;
197
    }
198
199
    /**
200
     * @code 1489765133
201
     *
202
     * @param string $name
203
     * @return self
204
     */
205
    final public static function configurationFieldNotFound($name)
206
    {
207
        /** @var self $exception */
208
        $exception = self::getNewExceptionInstance(
209
            self::CONFIGURATION_FIELD_NOT_FOUND,
210
            [$name, FormDefinition::class]
211
        );
212
213
        return $exception;
214
    }
215
216
    /**
217
     * @code 1487672276
218
     *
219
     * @param string $name
220
     * @return self
221
     */
222
    final public static function validatorNotFound($name)
223
    {
224
        /** @var self $exception */
225
        $exception = self::getNewExceptionInstance(
226
            self::VALIDATOR_NOT_FOUND,
227
            [$name, Field::class]
228
        );
229
230
        return $exception;
231
    }
232
233
    /**
234
     * @code 1494685753
235
     *
236
     * @param string $name
237
     * @return self
238
     */
239
    final public static function behaviourNotFound($name)
240
    {
241
        /** @var self $exception */
242
        $exception = self::getNewExceptionInstance(
243
            self::BEHAVIOUR_NOT_FOUND,
244
            [$name, Field::class]
245
        );
246
247
        return $exception;
248
    }
249
250
    /**
251
     * @code 1494694474
252
     *
253
     * @param string $name
254
     * @return self
255
     */
256
    final public static function messageNotFound($name)
257
    {
258
        /** @var self $exception */
259
        $exception = self::getNewExceptionInstance(
260
            self::MESSAGE_NOT_FOUND,
261
            [$name, Validator::class]
262
        );
263
264
        return $exception;
265
    }
266
267
    /**
268
     * @code 1489753952
269
     *
270
     * @param string $name
271
     * @return self
272
     */
273
    final public static function viewLayoutNotFound($name)
274
    {
275
        /** @var self $exception */
276
        $exception = self::getNewExceptionInstance(
277
            self::VIEW_LAYOUT_NOT_FOUND,
278
            [$name, View::class]
279
        );
280
281
        return $exception;
282
    }
283
284
    /**
285
     * @code 1489757511
286
     *
287
     * @param string $name
288
     * @return self
289
     */
290
    final public static function viewLayoutItemNotFound($name)
291
    {
292
        /** @var self $exception */
293
        $exception = self::getNewExceptionInstance(
294
            self::VIEW_LAYOUT_ITEM_NOT_FOUND,
295
            [$name, LayoutGroup::class]
296
        );
297
298
        return $exception;
299
    }
300
301
    /**
302
     * @code 1489754909
303
     *
304
     * @param string $name
305
     * @return self
306
     */
307
    final public static function viewClassNotFound($name)
308
    {
309
        /** @var self $exception */
310
        $exception = self::getNewExceptionInstance(
311
            self::VIEW_CLASS_NOT_FOUND,
312
            [$name, ViewClass::class]
313
        );
314
315
        return $exception;
316
    }
317
318
    /**
319
     * @code 1487672956
320
     *
321
     * @param string $validationName
322
     * @param string $fieldName
323
     * @return self
324
     */
325
    final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName)
326
    {
327
        /** @var self $exception */
328
        $exception = self::getNewExceptionInstance(
329
            self::VALIDATION_NOT_FOUND_FOR_FIELD,
330
            [$fieldName, $validationName]
331
        );
332
333
        return $exception;
334
    }
335
336
    /**
337
     * @code 1487671603
338
     *
339
     * @param string     $fieldName
340
     * @param FormObject $formObject
341
     * @return self
342
     */
343
    final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject)
344
    {
345
        /** @var self $exception */
346
        $exception = self::getNewExceptionInstance(
347
            self::FIELD_NOT_FOUND,
348
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
349
        );
350
351
        return $exception;
352
    }
353
354
    /**
355
     * @code 1455272659
356
     *
357
     * @param string            $key
358
     * @param AbstractValidator $validator
359
     * @return self
360
     */
361
    final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator)
362
    {
363
        /** @var self $exception */
364
        $exception = self::getNewExceptionInstance(
365
            self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR,
366
            [$key, get_class($validator)]
367
        );
368
369
        return $exception;
370
    }
371
372
    /**
373
     * @code 1487947224
374
     *
375
     * @param string     $fieldName
376
     * @param FormObject $formObject
377
     * @return self
378
     */
379
    final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject)
380
    {
381
        /** @var self $exception */
382
        $exception = self::getNewExceptionInstance(
383
            self::FIELD_NOT_FOUND,
384
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
385
        );
386
387
        return $exception;
388
    }
389
390
    /**
391
     * @code 1467623761
392
     *
393
     * @return self
394
     */
395
    final public static function classViewHelperFieldNotFound()
396
    {
397
        /** @var self $exception */
398
        $exception = self::getNewExceptionInstance(
399
            self::VIEW_HELPER_FIELD_NOT_FOUND,
400
            [ClassViewHelper::class, FieldViewHelper::class]
401
        );
402
403
        return $exception;
404
    }
405
406
    /**
407
     * @code 1467624152
408
     *
409
     * @param string $fieldName
410
     * @return self
411
     */
412
    final public static function formatMessageViewHelperFieldNotFound($fieldName)
413
    {
414
        /** @var self $exception */
415
        $exception = self::getNewExceptionInstance(
416
            self::VIEW_HELPER_FIELD_NOT_FOUND,
417
            [$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class]
418
        );
419
420
        return $exception;
421
    }
422
423
    /**
424
     * @code 1465243586
425
     *
426
     * @param string $layoutName
427
     * @return self
428
     */
429
    final public static function fieldViewHelperLayoutNotFound($layoutName)
430
    {
431
        /** @var self $exception */
432
        $exception = self::getNewExceptionInstance(
433
            self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND,
434
            [$layoutName]
435
        );
436
437
        return $exception;
438
    }
439
440
    /**
441
     * @code 1485867803
442
     *
443
     * @param string $layoutName
444
     * @param string $itemName
445
     * @return self
446
     */
447
    final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName)
448
    {
449
        /** @var self $exception */
450
        $exception = self::getNewExceptionInstance(
451
            self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND,
452
            [$layoutName, $itemName]
453
        );
454
455
        return $exception;
456
    }
457
458
    /**
459
     * @code 1473084335
460
     *
461
     * @param string     $fieldName
462
     * @param FormObject $formObject
463
     * @return self
464
     */
465
    final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject)
466
    {
467
        /** @var self $exception */
468
        $exception = self::getNewExceptionInstance(
469
            self::FIELD_NOT_FOUND,
470
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
471
        );
472
473
        return $exception;
474
    }
475
476
    /**
477
     * @code 1457441846
478
     *
479
     * @param string $controllerObjectName
480
     * @param string $actionName
481
     * @param string $formName
482
     * @return self
483
     */
484
    final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName)
485
    {
486
        /** @var self $exception */
487
        $exception = self::getNewExceptionInstance(
488
            self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING,
489
            [$controllerObjectName, $actionName . 'Action', $formName]
490
        );
491
492
        return $exception;
493
    }
494
495
    /**
496
     * @code 1488988452
497
     *
498
     * @param string $name
499
     * @return self
500
     */
501
    final public static function slotClosureSlotNotFound($name)
502
    {
503
        /** @var self $exception */
504
        $exception = self::getNewExceptionInstance(
505
            self::SLOT_NOT_FOUND,
506
            [$name]
507
        );
508
509
        return $exception;
510
    }
511
512
    /**
513
     * @code 1489497046
514
     *
515
     * @param string $name
516
     * @return self
517
     */
518
    final public static function slotArgumentsSlotNotFound($name)
519
    {
520
        /** @var self $exception */
521
        $exception = self::getNewExceptionInstance(
522
            self::SLOT_NOT_FOUND,
523
            [$name]
524
        );
525
526
        return $exception;
527
    }
528
529
    /**
530
     * @code 1490792697
531
     *
532
     * @param string $name
533
     * @return self
534
     */
535
    final public static function argumentNotFound($name)
536
    {
537
        /** @var self $exception */
538
        $exception = self::getNewExceptionInstance(
539
            self::ARGUMENT_NOT_FOUND,
540
            [$name]
541
        );
542
543
        return $exception;
544
    }
545
546
    /**
547
     * @code 1490799273
548
     *
549
     * @param string $name
550
     * @return self
551
     */
552
    final public static function formRequestDataNotFound($name)
553
    {
554
        /** @var self $exception */
555
        $exception = self::getNewExceptionInstance(
556
            self::FORM_REQUEST_DATA_NOT_FOUND,
557
            [$name, FormObjectRequestData::class]
558
        );
559
560
        return $exception;
561
    }
562
563
    /**
564
     * @code 1491997168
565
     *
566
     * @return self
567
     */
568
    final public static function formConfigurationNotFound()
569
    {
570
        /** @var self $exception */
571
        $exception = self::getNewExceptionInstance(
572
            self::FORM_CONFIGURATION_NOT_FOUND,
573
            [Configuration::class]
574
        );
575
576
        return $exception;
577
    }
578
579
    /**
580
     * @code 1493881671
581
     *
582
     * @param string $name
583
     * @return self
584
     */
585
    final public static function conditionNotFoundInDefinition($name)
586
    {
587
        /** @var self $exception */
588
        $exception = self::getNewExceptionInstance(
589
            self::CONDITION_NOT_FOUND_IN_DEFINITION,
590
            [$name, Configuration::class]
591
        );
592
593
        return $exception;
594
    }
595
596
    /**
597
     * @code 1491997309
598
     *
599
     * @param string $name
600
     * @return self
601
     */
602
    final public static function middlewareNotFound($name)
603
    {
604
        /** @var self $exception */
605
        $exception = self::getNewExceptionInstance(
606
            self::MIDDLEWARE_NOT_FOUND,
607
            [$name, FormDefinition::class]
608
        );
609
610
        return $exception;
611
    }
612
613
    /**
614
     * @code 1494514957
615
     *
616
     * @param FormInterface $form
617
     * @return self
618
     */
619
    final public static function formObjectInstanceNotFound(FormInterface $form)
620
    {
621
        /** @var self $exception */
622
        $exception = self::getNewExceptionInstance(
623
            self::FORM_OBJECT_INSTANCE_NOT_FOUND,
624
            [get_class($form), FormObjectFactory::class]
625
        );
626
627
        return $exception;
628
    }
629
}
630