Skip to content

Commit 78a9478

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Workflow] Add type information for multiple state marking store
2 parents a95ecd1 + aece722 commit 78a9478

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

workflow.rst

+35
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,41 @@ what actions are allowed on a blog post::
279279
// See a specific available transition for the post in the current state
280280
$transition = $workflow->getEnabledTransition($post, 'publish');
281281

282+
Using a multiple state marking store
283+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284+
285+
If you are creating a :doc:`workflow </workflow/workflow-and-state-machine>`,
286+
your marking store may need to contain multiple places at the same time. That's why,
287+
if you are using Doctrine, the matching column definition should use the type ``json``::
288+
289+
// src/Entity/BlogPost.php
290+
namespace App\Entity;
291+
292+
use Doctrine\DBAL\Types\Types;
293+
use Doctrine\ORM\Mapping as ORM;
294+
295+
#[ORM\Entity]
296+
class BlogPost
297+
{
298+
#[ORM\Id]
299+
#[ORM\GeneratedValue]
300+
#[ORM\Column]
301+
private int $id;
302+
303+
#[ORM\Column(type: Types::JSON)]
304+
private array $currentPlaces;
305+
306+
// ...
307+
}
308+
309+
.. caution::
310+
311+
You should not use the type ``simple_array`` for your marking store. Inside
312+
a multiple state marking store, places are stored as keys with a value of one,
313+
such as ``['draft' => 1]``. If the marking store contains only one place,
314+
this Doctrine type will store its value only as a string, resulting in the
315+
loss of the object's current place.
316+
282317
Accessing the Workflow in a Class
283318
---------------------------------
284319

0 commit comments

Comments
 (0)