From 1e6ec525a349e230f33f7c3469adb5501b92b630 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 1 Aug 2023 10:32:17 +0200 Subject: [PATCH] [Workflow] Allow using public properties for the marking store --- workflow.rst | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/workflow.rst b/workflow.rst index b97cb08c1c3..182b2aed825 100644 --- a/workflow.rst +++ b/workflow.rst @@ -190,12 +190,48 @@ The configured property will be used via its implemented getter/setter methods b return $this->currentPlace; } - public function setCurrentPlace($currentPlace, $context = []): void + public function setCurrentPlace(string $currentPlace, array $context = []): void { $this->currentPlace = $currentPlace; } } +It is also possible to use public properties to be used by the marking +store. The above class would become the following:: + + // src/Entity/BlogPost.php + namespace App\Entity; + + class BlogPost + { + // the configured marking store property must be declared + public string $currentPlace; + public string $title; + public string $content; + } + +When using public properties, context is not supported. In order +to support it, you must declare a setter to write your property:: + + // src/Entity/BlogPost.php + namespace App\Entity; + + class BlogPost + { + public string $currentPlace; + // ... + + public function setCurrentPlace(string $currentPlace, array $context = []): void + { + // Assign the property and so something with `$context` + } + } + +.. versionadded:: 6.4 + + The support of using public properties instead of getter/setter methods + and private properties was introduced in Symfony 6.4. + .. note:: The marking store type could be "multiple_state" or "single_state". A single