diff --git a/workflow.rst b/workflow.rst index 99d23cdcfae..7e45c7693c1 100644 --- a/workflow.rst +++ b/workflow.rst @@ -60,7 +60,7 @@ follows: supports: - App\Entity\BlogPost initial_marking: draft - places: + places: # defining places manually is optional - draft - reviewed - rejected @@ -97,10 +97,13 @@ follows: App\Entity\BlogPost draft + + draft reviewed rejected published + draft reviewed @@ -135,6 +138,7 @@ follows: ->type('method') ->property('currentPlace'); + // defining places manually is optional $blogPublishing->place()->name('draft'); $blogPublishing->place()->name('reviewed'); $blogPublishing->place()->name('rejected'); @@ -168,6 +172,17 @@ follows: ``'draft'`` or ``!php/const App\Entity\BlogPost::TRANSITION_TO_REVIEW`` instead of ``'to_review'``. +.. tip:: + + You can omit the ``places`` option if your transitions define all the places + that are used in the workflow. Symfony will automatically extract the places + from the transitions. + + .. versionadded:: 7.1 + + The support for omitting the ``places`` option was introduced in + Symfony 7.1. + The configured property will be used via its implemented getter/setter methods by the marking store:: // src/Entity/BlogPost.php diff --git a/workflow/workflow-and-state-machine.rst b/workflow/workflow-and-state-machine.rst index e72b50f8d1e..04abf590f2f 100644 --- a/workflow/workflow-and-state-machine.rst +++ b/workflow/workflow-and-state-machine.rst @@ -252,6 +252,17 @@ Below is the configuration for the pull request state machine. ->to(['review']); }; +.. tip:: + + You can omit the ``places`` option if your transitions define all the places + that are used in the workflow. Symfony will automatically extract the places + from the transitions. + + .. versionadded:: 7.1 + + The support for omitting the ``places`` option was introduced in + Symfony 7.1. + Symfony automatically creates a service for each workflow (:class:`Symfony\\Component\\Workflow\\Workflow`) or state machine (:class:`Symfony\\Component\\Workflow\\StateMachine`) you have defined in your configuration. You can use the workflow inside a class by using