Completed
Push — middleware-wip-tmp2 ( 51115e...a3478c )
by Romain
02:39
created

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