Completed
Push — feature/improve-form-definitio... ( dfeaeb...ef7fcf )
by Romain
05:07
created

activationAddConditionNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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