|
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 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.'; |
|
25
|
|
|
|
|
26
|
|
|
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.'; |
|
27
|
|
|
|
|
28
|
|
|
const CONFIGURATION_OBJECT_FROZEN_PROPERTY = 'The property "%s::$%s" cannot be modified this way.'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @code 1465243619 |
|
32
|
|
|
* |
|
33
|
|
|
* @param FormObject $formObject |
|
34
|
|
|
* @param string $fieldName |
|
35
|
|
|
* @return self |
|
36
|
|
|
*/ |
|
37
|
|
|
final public static function fieldViewHelperFieldNotAccessibleInForm(FormObject $formObject, $fieldName) |
|
38
|
|
|
{ |
|
39
|
|
|
/** @var self $exception */ |
|
40
|
|
|
$exception = self::getNewExceptionInstance( |
|
41
|
|
|
self::FIELD_NOT_ACCESSIBLE_IN_FORM, |
|
42
|
|
|
[$formObject->getClassName(), $fieldName] |
|
43
|
|
|
); |
|
44
|
|
|
|
|
45
|
|
|
return $exception; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @code 1491815527 |
|
50
|
|
|
* |
|
51
|
|
|
* @return self |
|
52
|
|
|
*/ |
|
53
|
|
|
final public static function formInstanceNotSet() |
|
54
|
|
|
{ |
|
55
|
|
|
/** @var self $exception */ |
|
56
|
|
|
$exception = self::getNewExceptionInstance(self::FORM_INSTANCE_NOT_SET); |
|
57
|
|
|
|
|
58
|
|
|
return $exception; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @code 1494839287 |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $className |
|
65
|
|
|
* @param string $methodName |
|
66
|
|
|
* @return self |
|
67
|
|
|
*/ |
|
68
|
|
|
final public static function rootConfigurationFrozenMethod($className, $methodName) |
|
69
|
|
|
{ |
|
70
|
|
|
/** @var self $exception */ |
|
71
|
|
|
$exception = self::getNewExceptionInstance( |
|
72
|
|
|
self::ROOT_CONFIGURATION_FROZEN_METHOD, |
|
73
|
|
|
[$className, $methodName] |
|
74
|
|
|
); |
|
75
|
|
|
|
|
76
|
|
|
return $exception; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @code 1494839741 |
|
81
|
|
|
* |
|
82
|
|
|
* @param string $className |
|
83
|
|
|
* @param string $propertyName |
|
84
|
|
|
* @return self |
|
85
|
|
|
*/ |
|
86
|
|
|
final public static function rootConfigurationFrozenProperty($className, $propertyName) |
|
87
|
|
|
{ |
|
88
|
|
|
/** @var self $exception */ |
|
89
|
|
|
$exception = self::getNewExceptionInstance( |
|
90
|
|
|
self::CONFIGURATION_OBJECT_FROZEN_PROPERTY, |
|
91
|
|
|
[$className, $propertyName] |
|
92
|
|
|
); |
|
93
|
|
|
|
|
94
|
|
|
return $exception; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @code 1494440357 |
|
99
|
|
|
* |
|
100
|
|
|
* @param string $className |
|
101
|
|
|
* @param string $methodName |
|
102
|
|
|
* @return self |
|
103
|
|
|
*/ |
|
104
|
|
|
final public static function formDefinitionFrozenMethod($className, $methodName) |
|
105
|
|
|
{ |
|
106
|
|
|
/** @var self $exception */ |
|
107
|
|
|
$exception = self::getNewExceptionInstance( |
|
108
|
|
|
self::FORM_DEFINITION_FROZEN_METHOD, |
|
109
|
|
|
[$className, $methodName] |
|
110
|
|
|
); |
|
111
|
|
|
|
|
112
|
|
|
return $exception; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @code 1494440395 |
|
117
|
|
|
* |
|
118
|
|
|
* @param string $className |
|
119
|
|
|
* @param string $propertyName |
|
120
|
|
|
* @return self |
|
121
|
|
|
*/ |
|
122
|
|
|
final public static function formDefinitionFrozenProperty($className, $propertyName) |
|
123
|
|
|
{ |
|
124
|
|
|
/** @var self $exception */ |
|
125
|
|
|
$exception = self::getNewExceptionInstance( |
|
126
|
|
|
self::CONFIGURATION_OBJECT_FROZEN_PROPERTY, |
|
127
|
|
|
[$className, $propertyName] |
|
128
|
|
|
); |
|
129
|
|
|
|
|
130
|
|
|
return $exception; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|