Completed
Push — middleware-wip ( 1bcdac...ffd957 )
by Romain
02:46
created

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