-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
FormConfigBuilderInterface.php
260 lines (229 loc) · 7.16 KB
/
FormConfigBuilderInterface.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\EventSubscriberInterface;
use Symfony\Component\PropertyAccess\PropertyPathInterface;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface FormConfigBuilderInterface extends FormConfigInterface
{
/**
* Adds an event listener to an event on this form.
*
* @param int $priority The priority of the listener. Listeners
* with a higher priority are called before
* listeners with a lower priority.
*
* @return $this
*/
public function addEventListener(string $eventName, callable $listener, int $priority = 0): static;
/**
* Adds an event subscriber for events on this form.
*
* @return $this
*/
public function addEventSubscriber(EventSubscriberInterface $subscriber): static;
/**
* Appends / prepends a transformer to the view transformer chain.
*
* The transform method of the transformer is used to convert data from the
* normalized to the view format.
* The reverseTransform method of the transformer is used to convert from the
* view to the normalized format.
*
* @param bool $forcePrepend If set to true, prepend instead of appending
*
* @return $this
*/
public function addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false): static;
/**
* Clears the view transformers.
*
* @return $this
*/
public function resetViewTransformers(): static;
/**
* Prepends / appends a transformer to the normalization transformer chain.
*
* The transform method of the transformer is used to convert data from the
* model to the normalized format.
* The reverseTransform method of the transformer is used to convert from the
* normalized to the model format.
*
* @param bool $forceAppend If set to true, append instead of prepending
*
* @return $this
*/
public function addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false): static;
/**
* Clears the normalization transformers.
*
* @return $this
*/
public function resetModelTransformers(): static;
/**
* Sets the value for an attribute.
*
* @param mixed $value The value of the attribute
*
* @return $this
*/
public function setAttribute(string $name, mixed $value): static;
/**
* Sets the attributes.
*
* @return $this
*/
public function setAttributes(array $attributes): static;
/**
* Sets the data mapper used by the form.
*
* @return $this
*/
public function setDataMapper(?DataMapperInterface $dataMapper): static;
/**
* Sets whether the form is disabled.
*
* @return $this
*/
public function setDisabled(bool $disabled): static;
/**
* Sets the data used for the client data when no value is submitted.
*
* @param mixed $emptyData The empty data
*
* @return $this
*/
public function setEmptyData(mixed $emptyData): static;
/**
* Sets whether errors bubble up to the parent.
*
* @return $this
*/
public function setErrorBubbling(bool $errorBubbling): static;
/**
* Sets whether this field is required to be filled out when submitted.
*
* @return $this
*/
public function setRequired(bool $required): static;
/**
* Sets the property path that the form should be mapped to.
*
* @param string|PropertyPathInterface|null $propertyPath The property path or null if the path should be set
* automatically based on the form's name
*
* @return $this
*/
public function setPropertyPath(string|PropertyPathInterface|null $propertyPath): static;
/**
* Sets whether the form should be mapped to an element of its
* parent's data.
*
* @return $this
*/
public function setMapped(bool $mapped): static;
/**
* Sets whether the form's data should be modified by reference.
*
* @return $this
*/
public function setByReference(bool $byReference): static;
/**
* Sets whether the form should read and write the data of its parent.
*
* @return $this
*/
public function setInheritData(bool $inheritData): static;
/**
* Sets whether the form should be compound.
*
* @return $this
*
* @see FormConfigInterface::getCompound()
*/
public function setCompound(bool $compound): static;
/**
* Sets the resolved type.
*
* @return $this
*/
public function setType(ResolvedFormTypeInterface $type): static;
/**
* Sets the initial data of the form.
*
* @param mixed $data The data of the form in model format
*
* @return $this
*/
public function setData(mixed $data): static;
/**
* Locks the form's data to the data passed in the configuration.
*
* 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 or using PRE_SET_DATA event.
*
* It means data passed to a factory method or mapped from the
* parent will be ignored.
*
* @return $this
*/
public function setDataLocked(bool $locked): static;
/**
* Sets the form factory used for creating new forms.
*
* @return $this
*/
public function setFormFactory(FormFactoryInterface $formFactory): static;
/**
* Sets the target URL of the form.
*
* @return $this
*/
public function setAction(string $action): static;
/**
* Sets the HTTP method used by the form.
*
* @return $this
*/
public function setMethod(string $method): static;
/**
* Sets the request handler used by the form.
*
* @return $this
*/
public function setRequestHandler(RequestHandlerInterface $requestHandler): static;
/**
* Sets whether the form should be initialized automatically.
*
* Should be set to true only for root forms.
*
* @param bool $initialize True to initialize the form automatically,
* false to suppress automatic initialization.
* In the second case, you need to call
* {@link FormInterface::initialize()} manually.
*
* @return $this
*/
public function setAutoInitialize(bool $initialize): static;
/**
* Builds and returns the form configuration.
*/
public function getFormConfig(): FormConfigInterface;
/**
* Sets the callback that will be called to determine if the model
* data of the form is empty or not.
*
* @return $this
*/
public function setIsEmptyCallback(?callable $isEmptyCallback): static;
}