Skip to content

[Workflow] Support omitting places option #19551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ follows:
supports:
- App\Entity\BlogPost
initial_marking: draft
places:
places: # defining places manually is optional
- draft
- reviewed
- rejected
Expand Down Expand Up @@ -97,10 +97,13 @@ follows:
</framework:marking-store>
<framework:support>App\Entity\BlogPost</framework:support>
<framework:initial-marking>draft</framework:initial-marking>

<!-- defining places manually is optional -->
<framework:place>draft</framework:place>
<framework:place>reviewed</framework:place>
<framework:place>rejected</framework:place>
<framework:place>published</framework:place>

<framework:transition name="to_review">
<framework:from>draft</framework:from>
<framework:to>reviewed</framework:to>
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions workflow/workflow-and-state-machine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down