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\Form\FormObject\FormObject; |
17
|
|
|
|
18
|
|
|
class PropertyNotAccessibleException extends FormzException |
19
|
|
|
{ |
20
|
|
|
const FIELD_NOT_ACCESSIBLE_IN_FORM = 'The form "%s" does not have an accessible property "%s". Please be sure this property exists, and it has a proper getter to access its value.'; |
21
|
|
|
|
22
|
|
|
const FORM_INSTANCE_NOT_SET = 'The form instance is not accessible yet. You must use proxy methods after the form instance has been injected in the form object.'; |
23
|
|
|
|
24
|
|
|
const FORM_DEFINITION_FROZEN_METHOD = 'Trying to call the method "%s::%s()" when the form definition has been frozen. If you need to modify the form definition, you must do it in the form object builder only.'; |
25
|
|
|
|
26
|
|
|
const FORM_DEFINITION_FROZEN_PROPERTY = 'Trying to modify the property "%s::$%s" when the form definition has been frozen. If you need to modify the form definition, you must do it in the form object builder only.'; |
27
|
|
|
|
28
|
|
|
const ROOT_CONFIGURATION_FROZEN_METHOD = 'Trying to call the method "%s::%s()" when the root configuration has been frozen. If you need to modify the root configuration, you can use the post configuration process signal.'; |
29
|
|
|
|
30
|
|
|
const CONFIGURATION_OBJECT_FROZEN_PROPERTY = 'The property "%s::$%s" cannot be modified this way.'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @code 1465243619 |
34
|
|
|
* |
35
|
|
|
* @param FormObject $formObject |
36
|
|
|
* @param string $fieldName |
37
|
|
|
* @return self |
38
|
|
|
*/ |
39
|
|
|
final public static function fieldViewHelperFieldNotAccessibleInForm(FormObject $formObject, $fieldName) |
40
|
|
|
{ |
41
|
|
|
/** @var self $exception */ |
42
|
|
|
$exception = self::getNewExceptionInstance( |
43
|
|
|
self::FIELD_NOT_ACCESSIBLE_IN_FORM, |
44
|
|
|
[$formObject->getClassName(), $fieldName] |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
return $exception; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @code 1491815527 |
52
|
|
|
* |
53
|
|
|
* @return self |
54
|
|
|
*/ |
55
|
|
|
final public static function formInstanceNotSet() |
56
|
|
|
{ |
57
|
|
|
/** @var self $exception */ |
58
|
|
|
$exception = self::getNewExceptionInstance(self::FORM_INSTANCE_NOT_SET); |
59
|
|
|
|
60
|
|
|
return $exception; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @code 1494839287 |
65
|
|
|
* |
66
|
|
|
* @param string $className |
67
|
|
|
* @param string $methodName |
68
|
|
|
* @return self |
69
|
|
|
*/ |
70
|
|
|
final public static function rootConfigurationFrozenMethod($className, $methodName) |
71
|
|
|
{ |
72
|
|
|
/** @var self $exception */ |
73
|
|
|
$exception = self::getNewExceptionInstance( |
74
|
|
|
self::ROOT_CONFIGURATION_FROZEN_METHOD, |
75
|
|
|
[$className, $methodName] |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
return $exception; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @code 1494839741 |
83
|
|
|
* |
84
|
|
|
* @param string $className |
85
|
|
|
* @param string $propertyName |
86
|
|
|
* @return self |
87
|
|
|
*/ |
88
|
|
|
final public static function rootConfigurationFrozenProperty($className, $propertyName) |
89
|
|
|
{ |
90
|
|
|
/** @var self $exception */ |
91
|
|
|
$exception = self::getNewExceptionInstance( |
92
|
|
|
self::CONFIGURATION_OBJECT_FROZEN_PROPERTY, |
93
|
|
|
[$className, $propertyName] |
94
|
|
|
); |
95
|
|
|
|
96
|
|
|
return $exception; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @code 1494440357 |
101
|
|
|
* |
102
|
|
|
* @param string $className |
103
|
|
|
* @param string $methodName |
104
|
|
|
* @return self |
105
|
|
|
*/ |
106
|
|
|
final public static function formDefinitionFrozenMethod($className, $methodName) |
107
|
|
|
{ |
108
|
|
|
/** @var self $exception */ |
109
|
|
|
$exception = self::getNewExceptionInstance( |
110
|
|
|
self::FORM_DEFINITION_FROZEN_METHOD, |
111
|
|
|
[$className, $methodName] |
112
|
|
|
); |
113
|
|
|
|
114
|
|
|
return $exception; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @code 1494440395 |
119
|
|
|
* |
120
|
|
|
* @param string $className |
121
|
|
|
* @param string $propertyName |
122
|
|
|
* @return self |
123
|
|
|
*/ |
124
|
|
|
final public static function formDefinitionFrozenProperty($className, $propertyName) |
125
|
|
|
{ |
126
|
|
|
/** @var self $exception */ |
127
|
|
|
$exception = self::getNewExceptionInstance( |
128
|
|
|
self::CONFIGURATION_OBJECT_FROZEN_PROPERTY, |
129
|
|
|
[$className, $propertyName] |
130
|
|
|
); |
131
|
|
|
|
132
|
|
|
return $exception; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|