@@ -415,7 +415,7 @@ workflow leaves a place::
415
415
public function onLeave(Event $event)
416
416
{
417
417
$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"',
419
419
$event->getSubject()->getId(),
420
420
$event->getTransition()->getName(),
421
421
implode(', ', array_keys($event->getMarking()->getPlaces())),
@@ -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 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
443
443
of the guard event names.
444
444
445
445
* ``workflow.guard ``
@@ -460,15 +460,16 @@ 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 with no title should not be allowed
463
+ // Posts without title are not allowed
464
+ // to perform the transition "to_review"
464
465
$event->setBlocked(true);
465
466
}
466
467
}
467
468
468
469
public static function getSubscribedEvents()
469
470
{
470
471
return [
471
- 'workflow.blogpost .guard.to_review' => ['guardReview'],
472
+ 'workflow.blog_publishing .guard.to_review' => ['guardReview'],
472
473
];
473
474
}
474
475
}
@@ -583,7 +584,7 @@ transition was blocked::
583
584
public static function getSubscribedEvents()
584
585
{
585
586
return [
586
- 'workflow.blogpost .guard.publish' => ['guardPublish'],
587
+ 'workflow.blog_publishing .guard.publish' => ['guardPublish'],
587
588
];
588
589
}
589
590
}
@@ -618,6 +619,7 @@ You can access the message from a Twig template as follows:
618
619
The ``workflow_transition_blockers() `` Twig function was introduced in
619
620
Symfony 4.3.
620
621
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::
622
624
623
625
$event->setBlocked('true');
0 commit comments