File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -190,12 +190,48 @@ The configured property will be used via its implemented getter/setter methods b
190
190
return $this->currentPlace;
191
191
}
192
192
193
- public function setCurrentPlace($currentPlace, $context = []): void
193
+ public function setCurrentPlace(string $currentPlace, array $context = []): void
194
194
{
195
195
$this->currentPlace = $currentPlace;
196
196
}
197
197
}
198
198
199
+ It is also possible to use public properties to be used by the marking
200
+ store. The above class would become the following::
201
+
202
+ // src/Entity/BlogPost.php
203
+ namespace App\Entity;
204
+
205
+ class BlogPost
206
+ {
207
+ // the configured marking store property must be declared
208
+ public string $currentPlace;
209
+ public string $title;
210
+ public string $content;
211
+ }
212
+
213
+ When using public properties, context is not supported. In order
214
+ to support it, you must declare a setter to write your property::
215
+
216
+ // src/Entity/BlogPost.php
217
+ namespace App\Entity;
218
+
219
+ class BlogPost
220
+ {
221
+ public string $currentPlace;
222
+ // ...
223
+
224
+ public function setCurrentPlace(string $currentPlace, array $context = []): void
225
+ {
226
+ // Assign the property and so something with `$context`
227
+ }
228
+ }
229
+
230
+ .. versionadded :: 6.4
231
+
232
+ The support of using public properties instead of getter/setter methods
233
+ and private properties was introduced in Symfony 6.4.
234
+
199
235
.. note ::
200
236
201
237
The marking store type could be "multiple_state" or "single_state". A single
You can’t perform that action at this time.
0 commit comments