Completed
Push — unit-test-services ( 8af590...38d2eb )
by Romain
02:52
created

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