You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: workflow/usage.rst
+46-4Lines changed: 46 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -327,7 +327,7 @@ When a state transition is initiated, the events are dispatched in the following
327
327
order:
328
328
329
329
``workflow.guard``
330
-
Validate whether the transition is allowed at all (:ref:`see below <workflow-usage-guard-events>`).
330
+
Validate whether the transition is blocked or not (:ref:`see below <workflow-usage-guard-events>` and :ref:`using guards <workflow-usage-using-guards>`).
331
331
332
332
The three events being dispatched are:
333
333
@@ -439,7 +439,7 @@ Guard Events
439
439
There are a special kind of events called "Guard events". Their event listeners
440
440
are invoked every time a call to ``Workflow::can``, ``Workflow::apply`` or
441
441
``Workflow::getEnabledTransitions`` is executed. With the guard events you may
442
-
add custom logic to decide what transitions are valid or not. Here is a list
442
+
add custom logic to decide what transitions should be blocked or not. Here is a list
443
443
of the guard event names.
444
444
445
445
* ``workflow.guard``
@@ -460,8 +460,8 @@ See example to make sure no blog post without title is moved to "review"::
460
460
$title = $post->title;
461
461
462
462
if (empty($title)) {
463
-
// Posts without title are not allowed
464
-
// to perform the transition "to_review"
463
+
// Block the transition "to_review"
464
+
// if the post has no title defined
465
465
$event->setBlocked(true);
466
466
}
467
467
}
@@ -501,6 +501,48 @@ This class has two more methods:
0 commit comments