Completed
Push — middleware-wip ( 1ffb75...1f2854 )
by Romain
03:26
created

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