Skip to content

Commit af71c14

Browse files
committed
Add an introduction as suggested in #11209 (comment)
When #9465 is finished, link to details on Transition Blockers.
1 parent ca66356 commit af71c14

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

workflow/usage.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)