Completed
Push — middleware-wip ( 4ea7b3...161931 )
by Romain
03:37
created

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