Completed
Push — task/configuration-unit-tests ( 9e3c21...118c43 )
by Romain
02:40
created

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