@@ -248,6 +248,44 @@ what actions are allowed on a blog post::
248
248
// See a specific available transition for the post in the current state
249
249
$transition = $workflow->getEnabledTransition($post, 'publish');
250
250
251
+ Using a multiple state marking store
252
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253
+
254
+ If you are creating a :doc: `workflow </workflow/workflow-and-state-machine >`
255
+ , your marking store may need to contain multiple places at the same time.
256
+ If you are using Doctrine, the matching column definition should use the
257
+ type ``json `` ::
258
+
259
+ // src/Entity/BlogPost.php
260
+ namespace App\Entity;
261
+
262
+ use Doctrine\DBAL\Types\Types;
263
+ use Doctrine\ORM\Mapping as ORM;
264
+
265
+ #[ORM\Entity]
266
+ class BlogPost
267
+ {
268
+ #[ORM\Id]
269
+ #[ORM\GeneratedValue]
270
+ #[ORM\Column]
271
+ private int $id;
272
+
273
+ // Type declaration is not mandatory and
274
+ // matches the guessed value from Doctrine
275
+ #[ORM\Column(type: Types::JSON)] // or #[ORM\Column(type: 'json')]
276
+ private array $currentPlaces;
277
+
278
+ // ...
279
+ }
280
+
281
+ .. tip ::
282
+
283
+ You should not use the type ``simple_array `` for your marking store.
284
+ Inside a multiple state marking store, places are store as keys with
285
+ a value of one, such as ``['draft' => 1] ``. If the marking store contains
286
+ only one place, this Doctrine type will store its value only as a string,
287
+ resulting in the loss of the object's current place.
288
+
251
289
Accessing the Workflow in a Class
252
290
---------------------------------
253
291
0 commit comments