Completed
Push — middleware-wip ( 71b03c...531d78 )
by Romain
03:32
created

persistenceSessionEntryNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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