Completed
Push — task/introduce-controller-serv... ( f98b39 )
by Romain
03:13
created

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