Completed
Push — test/v2 ( 47461d )
by Romain
02:55 queued 35s
created

EntryNotFoundException   A

Complexity

Total Complexity 27

Size/Duplication

Total Lines 531
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 27
lcom 1
cbo 2
dl 0
loc 531
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 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
     * @return self
377
     */
378
    final public static function classViewHelperFieldNotFound()
379
    {
380
        /** @var self $exception */
381
        $exception = self::getNewExceptionInstance(
382
            self::VIEW_HELPER_FIELD_NOT_FOUND,
383
            [ClassViewHelper::class, FieldViewHelper::class]
384
        );
385
386
        return $exception;
387
    }
388
389
    /**
390
     * @code 1467624152
391
     *
392
     * @param string $fieldName
393
     * @return self
394
     */
395
    final public static function formatMessageViewHelperFieldNotFound($fieldName)
396
    {
397
        /** @var self $exception */
398
        $exception = self::getNewExceptionInstance(
399
            self::VIEW_HELPER_FIELD_NOT_FOUND,
400
            [$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class]
401
        );
402
403
        return $exception;
404
    }
405
406
    /**
407
     * @code 1465243586
408
     *
409
     * @param string $layoutName
410
     * @return self
411
     */
412
    final public static function fieldViewHelperLayoutNotFound($layoutName)
413
    {
414
        /** @var self $exception */
415
        $exception = self::getNewExceptionInstance(
416
            self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND,
417
            [$layoutName]
418
        );
419
420
        return $exception;
421
    }
422
423
    /**
424
     * @code 1485867803
425
     *
426
     * @param string $layoutName
427
     * @param string $itemName
428
     * @return self
429
     */
430
    final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName)
431
    {
432
        /** @var self $exception */
433
        $exception = self::getNewExceptionInstance(
434
            self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND,
435
            [$layoutName, $itemName]
436
        );
437
438
        return $exception;
439
    }
440
441
    /**
442
     * @code 1473084335
443
     *
444
     * @param string     $fieldName
445
     * @param FormObject $formObject
446
     * @return self
447
     */
448
    final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject)
449
    {
450
        /** @var self $exception */
451
        $exception = self::getNewExceptionInstance(
452
            self::FIELD_NOT_FOUND,
453
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
454
        );
455
456
        return $exception;
457
    }
458
459
    /**
460
     * @code 1457441846
461
     *
462
     * @param string $controllerObjectName
463
     * @param string $actionName
464
     * @param string $formName
465
     * @return self
466
     */
467
    final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName)
468
    {
469
        /** @var self $exception */
470
        $exception = self::getNewExceptionInstance(
471
            self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING,
472
            [$controllerObjectName, $actionName . 'Action', $formName]
473
        );
474
475
        return $exception;
476
    }
477
478
    /**
479
     * @code 1488988452
480
     *
481
     * @param string $name
482
     * @return self
483
     */
484
    final public static function slotClosureSlotNotFound($name)
485
    {
486
        /** @var self $exception */
487
        $exception = self::getNewExceptionInstance(
488
            self::SLOT_NOT_FOUND,
489
            [$name]
490
        );
491
492
        return $exception;
493
    }
494
495
    /**
496
     * @code 1489497046
497
     *
498
     * @param string $name
499
     * @return self
500
     */
501
    final public static function slotArgumentsSlotNotFound($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 1491997168
514
     *
515
     * @return self
516
     */
517
    final public static function formConfigurationNotFound()
518
    {
519
        /** @var self $exception */
520
        $exception = self::getNewExceptionInstance(
521
            self::FORM_CONFIGURATION_NOT_FOUND,
522
            [Configuration::class]
523
        );
524
525
        return $exception;
526
    }
527
528
    /**
529
     * @code 1493881671
530
     *
531
     * @param string $name
532
     * @return self
533
     */
534
    final public static function conditionNotFoundInDefinition($name)
535
    {
536
        /** @var self $exception */
537
        $exception = self::getNewExceptionInstance(
538
            self::CONDITION_NOT_FOUND_IN_DEFINITION,
539
            [$name, Configuration::class]
540
        );
541
542
        return $exception;
543
    }
544
545
    /**
546
     * @code 1494514957
547
     *
548
     * @param FormInterface $form
549
     * @return self
550
     */
551
    final public static function formObjectInstanceNotFound(FormInterface $form)
552
    {
553
        /** @var self $exception */
554
        $exception = self::getNewExceptionInstance(
555
            self::FORM_OBJECT_INSTANCE_NOT_FOUND,
556
            [get_class($form), FormObjectFactory::class]
557
        );
558
559
        return $exception;
560
    }
561
}
562