formatMessageViewHelperFieldNotFoundInForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 2
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
    /**
60
     * @param string $name
61
     * @param array  $list
62
     * @return self
63
     */
64
    final public static function conditionNotFound($name, array $list)
65
    {
66
        /** @var self $exception */
67
        $exception = self::getNewExceptionInstance(
68
            self::CONDITION_NOT_FOUND,
69
            1472650209,
70
            [
71
                $name,
72
                implode('" ,"', array_keys($list))
73
            ]
74
        );
75
76
        return $exception;
77
    }
78
79
    /**
80
     * @param string $name
81
     * @return self
82
     */
83
    final public static function activationConditionNotFound($name)
84
    {
85
        /** @var self $exception */
86
        $exception = self::getNewExceptionInstance(
87
            self::ACTIVATION_CONDITION_NOT_FOUND,
88
            1488482191,
89
            [$name]
90
        );
91
92
        return $exception;
93
    }
94
95
    /**
96
     * @param string $name
97
     * @return self
98
     */
99
    final public static function configurationFieldNotFound($name)
100
    {
101
        /** @var self $exception */
102
        $exception = self::getNewExceptionInstance(
103
            self::CONFIGURATION_FIELD_NOT_FOUND,
104
            1489765133,
105
            [$name, Form::class]
106
        );
107
108
        return $exception;
109
    }
110
111
    /**
112
     * @param string $name
113
     * @return self
114
     */
115
    final public static function validationNotFound($name)
116
    {
117
        /** @var self $exception */
118
        $exception = self::getNewExceptionInstance(
119
            self::VALIDATION_NOT_FOUND,
120
            1487672276,
121
            [$name, AbstractActivation::class]
122
        );
123
124
        return $exception;
125
    }
126
127
    /**
128
     * @param string $name
129
     * @return self
130
     */
131
    final public static function viewLayoutNotFound($name)
132
    {
133
        /** @var self $exception */
134
        $exception = self::getNewExceptionInstance(
135
            self::VIEW_LAYOUT_NOT_FOUND,
136
            1489753952,
137
            [$name, View::class]
138
        );
139
140
        return $exception;
141
    }
142
143
    /**
144
     * @param string $name
145
     * @return self
146
     */
147
    final public static function viewLayoutItemNotFound($name)
148
    {
149
        /** @var self $exception */
150
        $exception = self::getNewExceptionInstance(
151
            self::VIEW_LAYOUT_ITEM_NOT_FOUND,
152
            1489757511,
153
            [$name, LayoutGroup::class]
154
        );
155
156
        return $exception;
157
    }
158
159
    /**
160
     * @param string $name
161
     * @return self
162
     */
163
    final public static function viewClassNotFound($name)
164
    {
165
        /** @var self $exception */
166
        $exception = self::getNewExceptionInstance(
167
            self::VIEW_CLASS_NOT_FOUND,
168
            1489754909,
169
            [$name, ViewClass::class]
170
        );
171
172
        return $exception;
173
    }
174
175
    /**
176
     * @param string $validationName
177
     * @param string $fieldName
178
     * @return self
179
     */
180
    final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName)
181
    {
182
        /** @var self $exception */
183
        $exception = self::getNewExceptionInstance(
184
            self::VALIDATION_NOT_FOUND_FOR_FIELD,
185
            1487672956,
186
            [$fieldName, $validationName]
187
        );
188
189
        return $exception;
190
    }
191
192
    /**
193
     * @param string     $fieldName
194
     * @param FormObject $formObject
195
     * @return self
196
     */
197
    final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject)
198
    {
199
        /** @var self $exception */
200
        $exception = self::getNewExceptionInstance(
201
            self::FIELD_NOT_FOUND,
202
            1487671603,
203
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
204
        );
205
206
        return $exception;
207
    }
208
209
    /**
210
     * @param string            $key
211
     * @param AbstractValidator $validator
212
     * @return self
213
     */
214
    final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator)
215
    {
216
        /** @var self $exception */
217
        $exception = self::getNewExceptionInstance(
218
            self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR,
219
            1455272659,
220
            [$key, get_class($validator)]
221
        );
222
223
        return $exception;
224
    }
225
226
    /**
227
     * @param string     $fieldName
228
     * @param FormObject $formObject
229
     * @return self
230
     */
231
    final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject)
232
    {
233
        /** @var self $exception */
234
        $exception = self::getNewExceptionInstance(
235
            self::FIELD_NOT_FOUND,
236
            1487947224,
237
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
238
        );
239
240
        return $exception;
241
    }
242
243
    /**
244
     * @param string $fieldName
245
     * @return self
246
     */
247
    final public static function classViewHelperFieldNotFound($fieldName)
248
    {
249
        /** @var self $exception */
250
        $exception = self::getNewExceptionInstance(
251
            self::VIEW_HELPER_FIELD_NOT_FOUND,
252
            1467623761,
253
            [$fieldName, ClassViewHelper::class, FieldViewHelper::class]
254
        );
255
256
        return $exception;
257
    }
258
259
    /**
260
     * @param string $fieldName
261
     * @return self
262
     */
263
    final public static function formatMessageViewHelperFieldNotFound($fieldName)
264
    {
265
        /** @var self $exception */
266
        $exception = self::getNewExceptionInstance(
267
            self::VIEW_HELPER_FIELD_NOT_FOUND,
268
            1467624152,
269
            [$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class]
270
        );
271
272
        return $exception;
273
    }
274
275
    /**
276
     * @param string $layoutName
277
     * @return self
278
     */
279
    final public static function fieldViewHelperLayoutNotFound($layoutName)
280
    {
281
        /** @var self $exception */
282
        $exception = self::getNewExceptionInstance(
283
            self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND,
284
            1465243586,
285
            [$layoutName]
286
        );
287
288
        return $exception;
289
    }
290
291
    /**
292
     * @param string $layoutName
293
     * @param string $itemName
294
     * @return self
295
     */
296
    final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName)
297
    {
298
        /** @var self $exception */
299
        $exception = self::getNewExceptionInstance(
300
            self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND,
301
            1485867803,
302
            [$layoutName, $itemName]
303
        );
304
305
        return $exception;
306
    }
307
308
    /**
309
     * @param string     $fieldName
310
     * @param FormObject $formObject
311
     * @return self
312
     */
313
    final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject)
314
    {
315
        /** @var self $exception */
316
        $exception = self::getNewExceptionInstance(
317
            self::FIELD_NOT_FOUND,
318
            1473084335,
319
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
320
        );
321
322
        return $exception;
323
    }
324
325
    /**
326
     * @param string $controllerObjectName
327
     * @param string $actionName
328
     * @param string $formName
329
     * @return self
330
     */
331
    final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName)
332
    {
333
        /** @var self $exception */
334
        $exception = self::getNewExceptionInstance(
335
            self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING,
336
            1457441846,
337
            [$controllerObjectName, $actionName . 'Action', $formName]
338
        );
339
340
        return $exception;
341
    }
342
343
    /**
344
     * @param string $name
345
     * @return self
346
     */
347
    final public static function slotClosureSlotNotFound($name)
348
    {
349
        /** @var self $exception */
350
        $exception = self::getNewExceptionInstance(
351
            self::SLOT_NOT_FOUND,
352
            1488988452,
353
            [$name]
354
        );
355
356
        return $exception;
357
    }
358
359
    /**
360
     * @param string $name
361
     * @return self
362
     */
363
    final public static function slotArgumentsSlotNotFound($name)
364
    {
365
        /** @var self $exception */
366
        $exception = self::getNewExceptionInstance(
367
            self::SLOT_NOT_FOUND,
368
            1489497046,
369
            [$name]
370
        );
371
372
        return $exception;
373
    }
374
}
375