10000 Documented the workflow metadata [redux] by pbowyer · Pull Request #11209 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Documented the workflow metadata [redux] #11209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 17, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add an introduction as suggested in #11209 (comment)
When #9465 is finished, link to details on Transition Blockers.
  • Loading branch information
pbowyer committed Apr 7, 2019
commit af71c1427bc8bfe78f5fcf963f57f8641e30c564
12 changes: 10 additions & 2 deletions workflow/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,15 @@ In a Flash message in your Controller::
$title = $workflow->getMetadataStore()->getMetadata('title', $transition);
$this->addFlash('info', "You have successfully applied the transition with title: '$title'");

In a listener, access via the Event::
In a listener, access via the Event

Metadata can also be accessed in a Listener, from the Event object.

The example below uses a new feature introduced in 4.1 called Transition Blockers. These let you
return a user-friendly error message when you stop a transition from happening. In the example we
get this user-friendly message from the Event's metadata, giving you an easy place to manage the
text. This is a contrived example; in production systems you may prefer to use the
:doc:`Translation </components/translation>` component to manage text::

namespace App\Listener\Workflow\Task;

Expand All @@ -706,7 +714,7 @@ In a listener, access via the Event::
return;
}

$explanation = $event->getMetadata('explaination', $event->getTransition());
$explanation = $event->getMetadata('explanation', $event->getTransition());
$event->addTransitionBlocker(new TransitionBlocker($explanation , 0));
}

Expand Down
0