Completed
Push — middleware-wip ( 5cfd03...f2f782 )
by Romain
05:53
created

EntryNotFoundException   A

Complexity

Total Complexity 31

Size/Duplication

Total Lines 604
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 31
lcom 1
cbo 5
dl 0
loc 604
rs 9.8
c 0
b 0
f 0

31 Methods

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