Completed
Push — feature/improve-form-definitio... ( 22156e...9e9d4e )
by Romain
02:30
created

EntryNotFoundException::behaviourNotFound()   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\Form\Definition\Condition\Activation;
21
use Romm\Formz\Form\Definition\Field\Field;
22
use Romm\Formz\Form\Definition\FormDefinition;
23
use Romm\Formz\Form\FormObject\FormObject;
24
use Romm\Formz\Validation\Validator\AbstractValidator;
25
use Romm\Formz\ViewHelpers\ClassViewHelper;
26
use Romm\Formz\ViewHelpers\FieldViewHelper;
27
use Romm\Formz\ViewHelpers\FormatMessageViewHelper;
28
29
class EntryNotFoundException extends FormzException
30
{
31
    const FIELD_NOT_FOUND = 'The field "%s" was not found in the form "%s" with class "%s".';
32
33
    const CONDITION_NOT_FOUND = 'Trying to access a condition which is not registered: "%s". Here is a list of all currently registered conditions: "%s".';
34
35
    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".';
36
37
    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".';
38
39
    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".';
40
41
    const ACTIVATION_CONDITION_NOT_FOUND = 'No condition "%s" was found.';
42
43
    const CONFIGURATION_FIELD_NOT_FOUND = 'The field "%s" was not found. Please use the function `%s::hasField()` before.';
44
45
    const VALIDATOR_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidator()` before.';
46
47
    const BEHAVIOUR_NOT_FOUND = 'The behaviour "%s" was not found. Please use the function `%s::hasBehaviour()` before.';
48
49
    const VIEW_LAYOUT_NOT_FOUND = 'The layout "%s" was not found. Please use the function `%s::hasLayout()` before.';
50
51
    const VIEW_LAYOUT_ITEM_NOT_FOUND = 'The layout item "%s" was not found. Please use the function `%s::hasItem()` before.';
52
53
    const VIEW_CLASS_NOT_FOUND = 'The class "%s" was not found. Please use the function `%s::hasItem()` before.';
54
55
    const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".';
56
57
    const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".';
58
59
    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.';
60
61
    const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.';
62
63
    const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".';
64
65
    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.';
66
67
    const SLOT_NOT_FOUND = 'No slot "%s" was found.';
68
69
    const FORM_CONFIGURATION_NOT_FOUND = 'The configuration for form of class "%s" was not found. Please use the function `%s::hasForm()` before.';
70
71
    const CONDITION_NOT_FOUND_IN_DEFINITION = 'The condition "%s" was not found in the form definition. Please use the function `%s::hasCondition()` before.';
72
73
    const CONDITION_DOES_NOT_EXIST = 'The condition "%s" does not exist';
74
75
    /**
76
     * @code 1472650209
77
     *
78
     * @param string $identifier
79
     * @param array  $list
80
     * @return self
81
     */
82
    final public static function conditionNotFound($identifier, array $list)
83
    {
84
        /** @var self $exception */
85
        $exception = self::getNewExceptionInstance(
86
            self::CONDITION_NOT_FOUND,
87
            [
88
                $identifier,
89
                implode('" ,"', array_keys($list))
90
            ]
91
        );
92
93
        return $exception;
94
    }
95
96
    /**
97
     * @code 1493890438
98
     *
99
     * @param string $identifier
100
     * @param array  $list
101
     * @return self
102
     */
103
    final public static function formAddConditionNotFound($identifier, array $list)
104
    {
105
        /** @var self $exception */
106
        $exception = self::getNewExceptionInstance(
107
            self::FORM_ADD_CONDITION_NOT_FOUND,
108
            [
109
                $identifier,
110
                implode('" ,"', array_keys($list))
111
            ]
112
        );
113
114
        return $exception;
115
    }
116
117
    /**
118
     * @code 1494329341
119
     *
120
     * @param string $identifier
121
     * @param array  $list
122
     * @return self
123
     */
124
    final public static function activationAddConditionNotFound($identifier, array $list)
125
    {
126
        /** @var self $exception */
127
        $exception = self::getNewExceptionInstance(
128
            self::ACTIVATION_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, Field::class]
205
        );
206
207
        return $exception;
208
    }
209
210
    /**
211
     * @code 1494685753
212
     *
213
     * @param string $name
214
     * @return self
215
     */
216
    final public static function behaviourNotFound($name)
217
    {
218
        /** @var self $exception */
219
        $exception = self::getNewExceptionInstance(
220
            self::BEHAVIOUR_NOT_FOUND,
221
            [$name, Field::class]
222
        );
223
224
        return $exception;
225
    }
226
227
    /**
228
     * @code 1489753952
229
     *
230
     * @param string $name
231
     * @return self
232
     */
233
    final public static function viewLayoutNotFound($name)
234
    {
235
        /** @var self $exception */
236
        $exception = self::getNewExceptionInstance(
237
            self::VIEW_LAYOUT_NOT_FOUND,
238
            [$name, View::class]
239
        );
240
241
        return $exception;
242
    }
243
244
    /**
245
     * @code 1489757511
246
     *
247
     * @param string $name
248
     * @return self
249
     */
250
    final public static function viewLayoutItemNotFound($name)
251
    {
252
        /** @var self $exception */
253
        $exception = self::getNewExceptionInstance(
254
            self::VIEW_LAYOUT_ITEM_NOT_FOUND,
255
            [$name, LayoutGroup::class]
256
        );
257
258
        return $exception;
259
    }
260
261
    /**
262
     * @code 1489754909
263
     *
264
     * @param string $name
265
     * @return self
266
     */
267
    final public static function viewClassNotFound($name)
268
    {
269
        /** @var self $exception */
270
        $exception = self::getNewExceptionInstance(
271
            self::VIEW_CLASS_NOT_FOUND,
272
            [$name, ViewClass::class]
273
        );
274
275
        return $exception;
276
    }
277
278
    /**
279
     * @code 1487672956
280
     *
281
     * @param string $validationName
282
     * @param string $fieldName
283
     * @return self
284
     */
285
    final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName)
286
    {
287
        /** @var self $exception */
288
        $exception = self::getNewExceptionInstance(
289
            self::VALIDATION_NOT_FOUND_FOR_FIELD,
290
            [$fieldName, $validationName]
291
        );
292
293
        return $exception;
294
    }
295
296
    /**
297
     * @code 1487671603
298
     *
299
     * @param string     $fieldName
300
     * @param FormObject $formObject
301
     * @return self
302
     */
303
    final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject)
304
    {
305
        /** @var self $exception */
306
        $exception = self::getNewExceptionInstance(
307
            self::FIELD_NOT_FOUND,
308
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
309
        );
310
311
        return $exception;
312
    }
313
314
    /**
315
     * @code 1455272659
316
     *
317
     * @param string            $key
318
     * @param AbstractValidator $validator
319
     * @return self
320
     */
321
    final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator)
322
    {
323
        /** @var self $exception */
324
        $exception = self::getNewExceptionInstance(
325
            self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR,
326
            [$key, get_class($validator)]
327
        );
328
329
        return $exception;
330
    }
331
332
    /**
333
     * @code 1487947224
334
     *
335
     * @param string     $fieldName
336
     * @param FormObject $formObject
337
     * @return self
338
     */
339
    final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject)
340
    {
341
        /** @var self $exception */
342
        $exception = self::getNewExceptionInstance(
343
            self::FIELD_NOT_FOUND,
344
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
345
        );
346
347
        return $exception;
348
    }
349
350
    /**
351
     * @code 1467623761
352
     *
353
     * @param string $fieldName
354
     * @return self
355
     */
356
    final public static function classViewHelperFieldNotFound($fieldName)
357
    {
358
        /** @var self $exception */
359
        $exception = self::getNewExceptionInstance(
360
            self::VIEW_HELPER_FIELD_NOT_FOUND,
361
            [$fieldName, ClassViewHelper::class, FieldViewHelper::class]
362
        );
363
364
        return $exception;
365
    }
366
367
    /**
368
     * @code 1467624152
369
     *
370
     * @param string $fieldName
371
     * @return self
372
     */
373
    final public static function formatMessageViewHelperFieldNotFound($fieldName)
374
    {
375
        /** @var self $exception */
376
        $exception = self::getNewExceptionInstance(
377
            self::VIEW_HELPER_FIELD_NOT_FOUND,
378
            [$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class]
379
        );
380
381
        return $exception;
382
    }
383
384
    /**
385
     * @code 1465243586
386
     *
387
     * @param string $layoutName
388
     * @return self
389
     */
390
    final public static function fieldViewHelperLayoutNotFound($layoutName)
391
    {
392
        /** @var self $exception */
393
        $exception = self::getNewExceptionInstance(
394
            self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND,
395
            [$layoutName]
396
        );
397
398
        return $exception;
399
    }
400
401
    /**
402
     * @code 1485867803
403
     *
404
     * @param string $layoutName
405
     * @param string $itemName
406
     * @return self
407
     */
408
    final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName)
409
    {
410
        /** @var self $exception */
411
        $exception = self::getNewExceptionInstance(
412
            self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND,
413
            [$layoutName, $itemName]
414
        );
415
416
        return $exception;
417
    }
418
419
    /**
420
     * @code 1473084335
421
     *
422
     * @param string     $fieldName
423
     * @param FormObject $formObject
424
     * @return self
425
     */
426
    final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject)
427
    {
428
        /** @var self $exception */
429
        $exception = self::getNewExceptionInstance(
430
            self::FIELD_NOT_FOUND,
431
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
432
        );
433
434
        return $exception;
435
    }
436
437
    /**
438
     * @code 1457441846
439
     *
440
     * @param string $controllerObjectName
441
     * @param string $actionName
442
     * @param string $formName
443
     * @return self
444
     */
445
    final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName)
446
    {
447
        /** @var self $exception */
448
        $exception = self::getNewExceptionInstance(
449
            self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING,
450
            [$controllerObjectName, $actionName . 'Action', $formName]
451
        );
452
453
        return $exception;
454
    }
455
456
    /**
457
     * @code 1488988452
458
     *
459
     * @param string $name
460
     * @return self
461
     */
462
    final public static function slotClosureSlotNotFound($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 1489497046
475
     *
476
     * @param string $name
477
     * @return self
478
     */
479
    final public static function slotArgumentsSlotNotFound($name)
480
    {
481
        /** @var self $exception */
482
        $exception = self::getNewExceptionInstance(
483
            self::SLOT_NOT_FOUND,
484
            [$name]
485
        );
486
487
        return $exception;
488
    }
489
490
    /**
491
     * @code 1491997168
492
     *
493
     * @return self
494
     */
495
    final public static function formConfigurationNotFound()
496
    {
497
        /** @var self $exception */
498
        $exception = self::getNewExceptionInstance(
499
            self::FORM_CONFIGURATION_NOT_FOUND,
500
            [Configuration::class]
501
        );
502
503
        return $exception;
504
    }
505
506
    /**
507
     * @code 1493881671
508
     *
509
     * @param string $name
510
     * @return self
511
     */
512
    final public static function conditionNotFoundInDefinition($name)
513
    {
514
        /** @var self $exception */
515
        $exception = self::getNewExceptionInstance(
516
            self::CONDITION_NOT_FOUND_IN_DEFINITION,
517
            [$name, Configuration::class]
518
        );
519
520
        return $exception;
521
    }
522
}
523