Completed
Push — middleware-wip ( 9da264...f499dc )
by Romain
03:03
created

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