Skip to content

Commit 789b053

Browse files
committed
Merge branch '4.2'
* 4.2: Update usage.rst
2 parents e4baf0a + 67ae1ae commit 789b053

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

workflow/usage.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ workflow leaves a place::
415415
public function onLeave(Event $event)
416416
{
417417
$this->logger->alert(sprintf(
418-
'Blog post (id: "%s") performed transaction "%s" from "%s" to "%s"',
418+
'Blog post (id: "%s") performed transition "%s" from "%s" to "%s"',
419419
$event->getSubject()->getId(),
420420
$event->getTransition()->getName(),
421421
implode(', ', array_keys($event->getMarking()->getPlaces())),
@@ -439,7 +439,7 @@ Guard Events
439439
There are a special kind of events called "Guard events". Their event listeners
440440
are invoked every time a call to ``Workflow::can``, ``Workflow::apply`` or
441441
``Workflow::getEnabledTransitions`` is executed. With the guard events you may
442-
add custom logic to decide what transitions that are valid or not. Here is a list
442+
add custom logic to decide what transitions are valid or not. Here is a list
443443
of the guard event names.
444444

445445
* ``workflow.guard``
@@ -460,15 +460,16 @@ See example to make sure no blog post without title is moved to "review"::
460460
$title = $post->title;
461461

462462
if (empty($title)) {
463-
// Posts with no title should not be allowed
463+
// Posts without title are not allowed
464+
// to perform the transition "to_review"
464465
$event->setBlocked(true);
465466
}
466467
}
467468

468469
public static function getSubscribedEvents()
469470
{
470471
return [
471-
'workflow.blogpost.guard.to_review' => ['guardReview'],
472+
'workflow.blog_publishing.guard.to_review' => ['guardReview'],
472473
];
473474
}
474475
}
@@ -583,7 +584,7 @@ transition was blocked::
583584
public static function getSubscribedEvents()
584585
{
585586
return [
586-
'workflow.blogpost.guard.publish' => ['guardPublish'],
587+
'workflow.blog_publishing.guard.publish' => ['guardPublish'],
587588
];
588589
}
589590
}
@@ -618,6 +619,7 @@ You can access the message from a Twig template as follows:
618619
The ``workflow_transition_blockers()`` Twig function was introduced in
619620
Symfony 4.3.
620621

621-
Don't need a human-readable message? You can still use::
622+
Don't need a human-readable message? You can also block a transition via a guard
623+
event using::
622624

623625
$event->setBlocked('true');

0 commit comments

Comments
 (0)