Completed
Push — feature/improve-form-definitio... ( 5df9ba...6ebf3c )
by Romain
02:15
created

EntryNotFoundException   A

Complexity

Total Complexity 27

Size/Duplication

Total Lines 532
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 27
lcom 1
cbo 2
dl 0
loc 532
rs 10
c 0
b 0
f 0

27 Methods

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