File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -688,7 +688,15 @@ In a Flash message in your Controller::
688
688
$title = $workflow->getMetadataStore()->getMetadata('title', $transition);
689
689
$this->addFlash('info', "You have successfully applied the transition with title: '$title'");
690
690
691
- In a listener, access via the Event::
691
+ In a listener, access via the Event
692
+
693
+ Metadata can also be accessed in a Listener, from the Event object.
694
+
695
+ The example below uses a new feature introduced in 4.1 called Transition Blockers. These let you
696
+ return a user-friendly error message when you stop a transition from happening. In the example we
697
+ get this user-friendly message from the Event's metadata, giving you an easy place to manage the
698
+ text. This is a contrived example; in production systems you may prefer to use the
699
+ :doc: `Translation </components/translation >` component to manage text::
692
700
693
701
namespace App\Listener\Workflow\Task;
694
702
@@ -706,7 +714,7 @@ In a listener, access via the Event::
706
714
return;
707
715
}
708
716
709
- $explanation = $event->getMetadata('explaination ', $event->getTransition());
717
+ $explanation = $event->getMetadata('explanation ', $event->getTransition());
710
718
$event->addTransitionBlocker(new TransitionBlocker($explanation , 0));
711
719
}
712
720
You can’t perform that action at this time.
0 commit comments