Completed
Push — middleware-wip ( 985e5e...1bcdac )
by Romain
13:46
created

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