Completed
Push — task/configuration-unit-tests ( 23860e )
by Romain
02:27
created

EntryNotFoundException::viewLayoutNotFound()   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\Condition\Activation\AbstractActivation;
17
use Romm\Formz\Configuration\View\View;
18
use Romm\Formz\Form\FormObject;
19
use Romm\Formz\Validation\Validator\AbstractValidator;
20
use Romm\Formz\ViewHelpers\ClassViewHelper;
21
use Romm\Formz\ViewHelpers\FieldViewHelper;
22
use Romm\Formz\ViewHelpers\FormatMessageViewHelper;
23
24
class EntryNotFoundException extends FormzException
25
{
26
    const FIELD_NOT_FOUND = 'The field "%s" was not found in the form "%s" with class "%s".';
27
28
    const CONDITION_NOT_FOUND = 'No condition "%s" was found.';
29
30
    const VALIDATION_NOT_FOUND = 'The validation "%s" was not found. Please use the function `%s::hasValidation()` before.';
31
32
    const VIEW_LAYOUT_NOT_FOUND = 'The layout "%s" was not found. Please use the function `%s::hasLayout()` before.';
33
34
    const VALIDATION_NOT_FOUND_FOR_FIELD = 'The field "%s" does not have a rule "%s".';
35
36
    const ERROR_KEY_NOT_FOUND_FOR_VALIDATOR = 'The error key "%s" does not exist for the validator "%s".';
37
38
    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.';
39
40
    const FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND = 'The layout "%s" could not be found. Please check your TypoScript configuration.';
41
42
    const FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND = 'The layout "%s" does not have an item "%s".';
43
44
    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.';
45
46
    const SLOT_NOT_FOUND = 'No slot "%s" was found.';
47
48
    /**
49
     * @code 1488482191
50
     *
51
     * @param string $name
52
     * @return self
53
     */
54
    final public static function conditionNotFound($name)
55
    {
56
        /** @var self $exception */
57
        $exception = self::getNewExceptionInstance(
58
            self::CONDITION_NOT_FOUND,
59
            [$name]
60
        );
61
62
        return $exception;
63
    }
64
65
    /**
66
     * @code 1487672276
67
     *
68
     * @param string $name
69
     * @return self
70
     */
71
    final public static function validationNotFound($name)
72
    {
73
        /** @var self $exception */
74
        $exception = self::getNewExceptionInstance(
75
            self::VALIDATION_NOT_FOUND,
76
            [$name, AbstractActivation::class]
77
        );
78
79
        return $exception;
80
    }
81
82
    /**
83
     * @code 1489753952
84
     *
85
     * @param string $name
86
     * @return self
87
     */
88
    final public static function viewLayoutNotFound($name)
89
    {
90
        /** @var self $exception */
91
        $exception = self::getNewExceptionInstance(
92
            self::VIEW_LAYOUT_NOT_FOUND,
93
            [$name, View::class]
94
        );
95
96
        return $exception;
97
    }
98
99
    /**
100
     * @code 1487672956
101
     *
102
     * @param string $validationName
103
     * @param string $fieldName
104
     * @return EntryNotFoundException
105
     */
106
    final public static function ajaxControllerValidationNotFoundForField($validationName, $fieldName)
107
    {
108
        /** @var self $exception */
109
        $exception = self::getNewExceptionInstance(
110
            self::VALIDATION_NOT_FOUND_FOR_FIELD,
111
            [$fieldName, $validationName]
112
        );
113
114
        return $exception;
115
    }
116
117
    /**
118
     * @code 1487671603
119
     *
120
     * @param string     $fieldName
121
     * @param FormObject $formObject
122
     * @return EntryNotFoundException
123
     */
124
    final public static function ajaxControllerFieldNotFound($fieldName, FormObject $formObject)
125
    {
126
        /** @var self $exception */
127
        $exception = self::getNewExceptionInstance(
128
            self::FIELD_NOT_FOUND,
129
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
130
        );
131
132
        return $exception;
133
    }
134
135
    /**
136
     * @code 1455272659
137
     *
138
     * @param string            $key
139
     * @param AbstractValidator $validator
140
     * @return EntryNotFoundException
141
     */
142
    final public static function errorKeyNotFoundForValidator($key, AbstractValidator $validator)
143
    {
144
        /** @var self $exception */
145
        $exception = self::getNewExceptionInstance(
146
            self::ERROR_KEY_NOT_FOUND_FOR_VALIDATOR,
147
            [$key, get_class($validator)]
148
        );
149
150
        return $exception;
151
    }
152
153
    /**
154
     * @code 1487947224
155
     *
156
     * @param string     $fieldName
157
     * @param FormObject $formObject
158
     * @return EntryNotFoundException
159
     */
160
    final public static function equalsToFieldValidatorFieldNotFound($fieldName, FormObject $formObject)
161
    {
162
        /** @var self $exception */
163
        $exception = self::getNewExceptionInstance(
164
            self::FIELD_NOT_FOUND,
165
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
166
        );
167
168
        return $exception;
169
    }
170
171
    /**
172
     * @code 1467623761
173
     *
174
     * @param string $fieldName
175
     * @return self
176
     */
177
    final public static function classViewHelperFieldNotFound($fieldName)
178
    {
179
        /** @var self $exception */
180
        $exception = self::getNewExceptionInstance(
181
            self::VIEW_HELPER_FIELD_NOT_FOUND,
182
            [$fieldName, ClassViewHelper::class, FieldViewHelper::class]
183
        );
184
185
        return $exception;
186
    }
187
188
    /**
189
     * @code 1467624152
190
     *
191
     * @param string $fieldName
192
     * @return self
193
     */
194
    final public static function formatMessageViewHelperFieldNotFound($fieldName)
195
    {
196
        /** @var self $exception */
197
        $exception = self::getNewExceptionInstance(
198
            self::VIEW_HELPER_FIELD_NOT_FOUND,
199
            [$fieldName, FormatMessageViewHelper::class, FieldViewHelper::class]
200
        );
201
202
        return $exception;
203
    }
204
205
    /**
206
     * @code 1465243586
207
     *
208
     * @param string $layoutName
209
     * @return self
210
     */
211
    final public static function fieldViewHelperLayoutNotFound($layoutName)
212
    {
213
        /** @var self $exception */
214
        $exception = self::getNewExceptionInstance(
215
            self::FIELD_VIEW_HELPER_LAYOUT_NOT_FOUND,
216
            [$layoutName]
217
        );
218
219
        return $exception;
220
    }
221
222
    /**
223
     * @code 1485867803
224
     *
225
     * @param string $layoutName
226
     * @param string $itemName
227
     * @return EntryNotFoundException
228
     */
229
    final public static function fieldViewHelperLayoutItemNotFound($layoutName, $itemName)
230
    {
231
        /** @var self $exception */
232
        $exception = self::getNewExceptionInstance(
233
            self::FIELD_VIEW_HELPER_LAYOUT_ITEM_NOT_FOUND,
234
            [$layoutName, $itemName]
235
        );
236
237
        return $exception;
238
    }
239
240
    /**
241
     * @code 1473084335
242
     *
243
     * @param string     $fieldName
244
     * @param FormObject $formObject
245
     * @return EntryNotFoundException
246
     */
247
    final public static function formatMessageViewHelperFieldNotFoundInForm($fieldName, FormObject $formObject)
248
    {
249
        /** @var self $exception */
250
        $exception = self::getNewExceptionInstance(
251
            self::FIELD_NOT_FOUND,
252
            [$fieldName, $formObject->getName(), $formObject->getClassName()]
253
        );
254
255
        return $exception;
256
    }
257
258
    /**
259
     * @code 1457441846
260
     *
261
     * @param string $controllerObjectName
262
     * @param string $actionName
263
     * @param string $formName
264
     * @return EntryNotFoundException
265
     */
266
    final public static function controllerServiceActionFormArgumentMissing($controllerObjectName, $actionName, $formName)
267
    {
268
        /** @var self $exception */
269
        $exception = self::getNewExceptionInstance(
270
            self::CONTROLLER_SERVICE_ACTION_FORM_ARGUMENT_MISSING,
271
            [$controllerObjectName, $actionName . 'Action', $formName]
272
        );
273
274
        return $exception;
275
    }
276
277
    /**
278
     * @code 1488988452
279
     *
280
     * @param string $name
281
     * @return self
282
     */
283
    final public static function slotClosureSlotNotFound($name)
284
    {
285
        /** @var self $exception */
286
        $exception = self::getNewExceptionInstance(
287
            self::SLOT_NOT_FOUND,
288
            [$name]
289
        );
290
291
        return $exception;
292
    }
293
294
    /**
295
     * @code 1489497046
296
     *
297
     * @param string $name
298
     * @return self
299
     */
300
    final public static function slotArgumentsSlotNotFound($name)
301
    {
302
        /** @var self $exception */
303
        $exception = self::getNewExceptionInstance(
304
            self::SLOT_NOT_FOUND,
305
            [$name]
306
        );
307
308
        return $exception;
309
    }
310
}
311