Skip to content

Commit 302d1a6

Browse files
committed
minor #18658 [Workflow] Allow using public properties for the marking store (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- [Workflow] Allow using public properties for the marking store Fix #18656 Commits ------- 1e6ec52 [Workflow] Allow using public properties for the marking store
2 parents 3392cc6 + 1e6ec52 commit 302d1a6

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

workflow.rst

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,48 @@ The configured property will be used via its implemented getter/setter methods b
190190
return $this->currentPlace;
191191
}
192192

193-
public function setCurrentPlace($currentPlace, $context = []): void
193+
public function setCurrentPlace(string $currentPlace, array $context = []): void
194194
{
195195
$this->currentPlace = $currentPlace;
196196
}
197197
}
198198

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+
199235
.. note::
200236

201237
The marking store type could be "multiple_state" or "single_state". A single

0 commit comments

Comments
 (0)