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 @@ -605,7 +605,15 @@ In a Flash message in your Controller::
605605 $title = $workflow->getMetadataStore()->getMetadata('title', $transition);
606606 $this->addFlash('info', "You have successfully applied the transition with title: '$title'");
607607
608- In a listener, access via the Event::
608+ In a listener, access via the Event
609+
610+ Metadata can also be accessed in a Listener, from the Event object.
611+
612+ The example below uses a new feature introduced in 4.1 called Transition Blockers. These let you
613+ return a user-friendly error message when you stop a transition from happening. In the example we
614+ get this user-friendly message from the Event's metadata, giving you an easy place to manage the
615+ text. This is a contrived example; in production systems you may prefer to use the
616+ :doc: `Translation </components/translation >` component to manage text::
609617
610618 namespace App\Listener\Workflow\Task;
611619
@@ -623,7 +631,7 @@ In a listener, access via the Event::
623631 return;
624632 }
625633
626- $explanation = $event->getMetadata('explaination ', $event->getTransition());
634+ $explanation = $event->getMetadata('explanation ', $event->getTransition());
627635 $event->addTransitionBlocker(new TransitionBlocker($explanation , 0));
628636 }
629637
You can’t perform that action at this time.
0 commit comments