Completed
Branch task/secure-ajax-controller (c67bc7)
by Romain
02:54
created

ajaxControllerFormClassNameNotFound()   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
class ClassNotFoundException extends FormzException
17
{
18
    const WRONG_ASSET_HANDLER_CLASS_NAME = 'Trying to get an asset handler with a wrong class name: "%s".';
19
20
    const WRONG_FORM_CLASS_NAME = 'Invalid form class name given: "%s".';
21
22
    const FORM_VIEW_HELPER_CLASS_NOT_FOUND = 'Invalid value for the form class name (current value: "%s"). You need to either fill the parameter `formClassName` in the view helper, or specify the type of the parameter `$%s` for the method "%s::%s()".';
23
24
    const BACKEND_CACHE_CLASS_NAME_NOT_FOUND = 'The cache class name given in configuration "config.tx_formz.settings.defaultBackendCache" was not found (current value: "%s")';
25
26
    const CONDITION_CLASS_NAME_NOT_FOUND = 'The class name for the condition "%s" was not found (given value: "%s").';
27
28
    /**
29
     * @code 1489602455
30
     *
31
     * @param string $name
32
     * @param string $className
33
     * @return self
34
     */
35
    final public static function conditionClassNameNotFound($name, $className)
36
    {
37
        /** @var self $exception */
38
        $exception = self::getNewExceptionInstance(
39
            self::CONDITION_CLASS_NAME_NOT_FOUND,
40
            [$name, $className]
41
        );
42
43
        return $exception;
44
    }
45
46
    /**
47
     * @code 1477468381
48
     *
49
     * @param string $className
50
     * @return self
51
     */
52
    final public static function wrongAssetHandlerClassName($className)
53
    {
54
        /** @var self $exception */
55
        $exception = self::getNewExceptionInstance(
56
            self::WRONG_ASSET_HANDLER_CLASS_NAME,
57
            [$className]
58
        );
59
60
        return $exception;
61
    }
62
63
    /**
64
     * @code 1467191011
65
     *
66
     * @param string $className
67
     * @return self
68
     */
69
    final public static function wrongFormClassName($className)
70
    {
71
        /** @var self $exception */
72
        $exception = self::getNewExceptionInstance(
73
            self::WRONG_FORM_CLASS_NAME,
74
            [$className]
75
        );
76
77
        return $exception;
78
    }
79
80
    /**
81
     * @code 1457442014
82
     *
83
     * @param string $formClassName
84
     * @param string $formName
85
     * @param string $controller
86
     * @param string $action
87
     * @return ClassNotFoundException
88
     */
89
    final public static function formViewHelperClassNotFound($formClassName, $formName, $controller, $action)
90
    {
91
        /** @var self $exception */
92
        $exception = self::getNewExceptionInstance(
93
            self::FORM_VIEW_HELPER_CLASS_NOT_FOUND,
94
            [$formClassName, $formName, $controller, $action . 'Action']
95
        );
96
97
        return $exception;
98
    }
99
100
    /**
101
     * @code 1488475103
102
     *
103
     * @param string $className
104
     * @return self
105
     */
106
    final public static function backendCacheClassNameNotFound($className)
107
    {
108
        /** @var self $exception */
109
        $exception = self::getNewExceptionInstance(
110
            self::BACKEND_CACHE_CLASS_NAME_NOT_FOUND,
111
            [$className]
112
        );
113
114
        return $exception;
115
    }
116
117
    /**
118
     * @code 1490179346
119
     *
120
     * @param string $className
121
     * @return self
122
     */
123
    final public static function ajaxControllerFormClassNameNotFound($className)
124
    {
125
        /** @var self $exception */
126
        $exception = self::getNewExceptionInstance(
127
            self::WRONG_FORM_CLASS_NAME,
128
            [$className]
129
        );
130
131
        return $exception;
132
    }
133
}
134