Skip to content

Commit 6fbe8d4

Browse files
committed
Rewords
1 parent 4fbca85 commit 6fbe8d4

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

workflow/usage.rst

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ When a state transition is initiated, the events are dispatched in the following
210210
order:
211211

212212
``workflow.guard``
213-
Validate whether the transition is blocked or not (:ref:`see below <workflow-usage-guard-events>` and :ref:`using guards <workflow-usage-using-guards>`).
213+
Validate whether the transition is blocked or not (see
214+
:ref:`guard events <workflow-usage-guard-events>` and
215+
:ref:`blocking transitions <workflow-blocking-transitions>`).
214216

215217
The three events being dispatched are:
216218

@@ -329,7 +331,8 @@ of the guard event names.
329331
* ``workflow.[workflow name].guard``
330332
* ``workflow.[workflow name].guard.[transition name]``
331333

332-
This example stops any blog post being transitioned to "reviewed" if it is missing a title::
334+
This example stops any blog post being transitioned to "reviewed" if it is
335+
missing a title::
333336

334337
use Symfony\Component\Workflow\Event\GuardEvent;
335338
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -343,8 +346,7 @@ This example stops any blog post being transitioned to "reviewed" if it is missi
343346
$title = $post->title;
344347

345348
if (empty($title)) {
346-
// Block the transition "to_review"
347-
// if the post has no title
349+
// Block the transition "to_review" if the post has no title
348350
$event->setBlocked(true);
349351
}
350352
}
@@ -388,24 +390,19 @@ This class has two more methods:
388390
:method:`Symfony\\Component\\Workflow\\Event\\GuardEvent::setBlocked`
389391
Sets the blocked value.
390392

391-
.. _workflow-usage-using-guards:
393+
.. _workflow-blocking-transitions:
392394

393-
Using Guards
394-
------------
395-
396-
The component has a guard logic to control the execution of your workflow on top of your configuration.
397-
398-
It allows you to execute your custom logic to decide if the transition is blocked or not, before actually
399-
applying this transition.
400-
401-
You have multiple optional ways to use guards in your workflow.
402-
403-
The first way is :ref:`with the guard event <workflow-usage-guard-events>`, which allows you to implement
404-
any desired feature.
395+
Blocking Transitions
396+
--------------------
405397

406-
Another one is via the configuration and its specific entry ``guard`` on a transition.
398+
The execution of the workflow can be controlled by executing custom logic to
399+
decide if the current transition is blocked or allowed before applying it. This
400+
feature is provided by "guards", which can be used in two ways.
407401

408-
This ``guard`` entry allows any expression that is valid for the Expression Language component:
402+
First, you can listen to :ref:`the guard events <workflow-usage-guard-events>`.
403+
Alternatively, you can define a ``guard`` configuration option for the
404+
transition. The value of this option is any valid expression created with the
405+
:doc:`ExpressionLanguage component </components/expression_language>`:
409406

410407
.. configuration-block::
411408

@@ -428,7 +425,7 @@ This ``guard`` entry allows any expression that is valid for the Expression Lang
428425
from: reviewed
429426
to: published
430427
reject:
431-
# or any valid expression language with "subject" refering to the post
428+
# or any valid expression language with "subject" referring to the post
432429
guard: "has_role("ROLE_ADMIN") and subject.isStatusReviewed()"
433430
from: reviewed
434431
to: rejected

0 commit comments

Comments
 (0)