forked from symfony/form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormConfigInterface.php
196 lines (163 loc) · 5.13 KB
/
FormConfigInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\PropertyAccess\PropertyPathInterface;
/**
* The configuration of a {@link Form} object.
*
* @author Bernhard Schussek <[email protected]>
*/
interface FormConfigInterface
{
/**
* Returns the event dispatcher used to dispatch form events.
*/
public function getEventDispatcher(): EventDispatcherInterface;
/**
* Returns the name of the form used as HTTP parameter.
*/
public function getName(): string;
/**
* Returns the property path that the form should be mapped to.
*/
public function getPropertyPath(): ?PropertyPathInterface;
/**
* Returns whether the form should be mapped to an element of its
* parent's data.
*/
public function getMapped(): bool;
/**
* Returns whether the form's data should be modified by reference.
*/
public function getByReference(): bool;
/**
* Returns whether the form should read and write the data of its parent.
*/
public function getInheritData(): bool;
/**
* Returns whether the form is compound.
*
* This property is independent of whether the form actually has
* children. A form can be compound and have no children at all, like
* for example an empty collection form.
* The contrary is not possible, a form which is not compound
* cannot have any children.
*/
public function getCompound(): bool;
/**
* Returns the resolved form type used to construct the form.
*/
public function getType(): ResolvedFormTypeInterface;
/**
* Returns the view transformers of the form.
*
* @return DataTransformerInterface[]
*/
public function getViewTransformers(): array;
/**
* Returns the model transformers of the form.
*
* @return DataTransformerInterface[]
*/
public function getModelTransformers(): array;
/**
* Returns the data mapper of the compound form or null for a simple form.
*/
public function getDataMapper(): ?DataMapperInterface;
/**
* Returns whether the form is required.
*/
public function getRequired(): bool;
/**
* Returns whether the form is disabled.
*/
public function getDisabled(): bool;
/**
* Returns whether errors attached to the form will bubble to its parent.
*/
public function getErrorBubbling(): bool;
/**
* Used when the view data is empty on submission.
*
* When the form is compound it will also be used to map the
* children data.
*
* The empty data must match the view format as it will passed to the first view transformer's
* "reverseTransform" method.
*/
public function getEmptyData(): mixed;
/**
* Returns additional attributes of the form.
*/
public function getAttributes(): array;
/**
* Returns whether the attribute with the given name exists.
*/
public function hasAttribute(string $name): bool;
/**
* Returns the value of the given attribute.
*/
public function getAttribute(string $name, mixed $default = null): mixed;
/**
* Returns the initial data of the form.
*/
public function getData(): mixed;
/**
* Returns the class of the view data or null if the data is scalar or an array.
*/
public function getDataClass(): ?string;
/**
* Returns whether the form's data is locked.
*
* A form with locked data is restricted to the data passed in
* this configuration. The data can only be modified then by
* submitting the form.
*/
public function getDataLocked(): bool;
/**
* Returns the form factory used for creating new forms.
*/
public function getFormFactory(): FormFactoryInterface;
/**
* Returns the target URL of the form.
*/
public function getAction(): string;
/**
* Returns the HTTP method used by the form.
*/
public function getMethod(): string;
/**
* Returns the request handler used by the form.
*/
public function getRequestHandler(): RequestHandlerInterface;
/**
* Returns whether the form should be initialized upon creation.
*/
public function getAutoInitialize(): bool;
/**
* Returns all options passed during the construction of the form.
*
* @return array<string, mixed> The passed options
*/
public function getOptions(): array;
/**
* Returns whether a specific option exists.
*/
public function hasOption(string $name): bool;
/**
* Returns the value of a specific option.
*/
public function getOption(string $name, mixed $default = null): mixed;
/**
* Returns a callable that takes the model data as argument and that returns if it is empty or not.
*/
public function getIsEmptyCallback(): ?callable;
}