Completed
Push — tmp-wip ( 51e3a7...57b785 )
by Romain
03:04
created

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