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::
688688 $title = $workflow->getMetadataStore()->getMetadata('title', $transition);
689689 $this->addFlash('info', "You have successfully applied the transition with title: '$title'");
690690
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::
692700
693701 namespace App\Listener\Workflow\Task;
694702
@@ -706,7 +714,7 @@ In a listener, access via the Event::
706714 return;
707715 }
708716
709- $explanation = $event->getMetadata('explaination ', $event->getTransition());
717+ $explanation = $event->getMetadata('explanation ', $event->getTransition());
710718 $event->addTransitionBlocker(new TransitionBlocker($explanation , 0));
711719 }
712720
You can’t perform that action at this time.
0 commit comments