Completed
Push — unit-test-services ( 99caba...a7c404 )
by Romain
02:14
created

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