8000 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
Incorporate @OskarStark's feedback
  • Loading branch information
pbowyer committed Apr 7, 2019
commit c9ef2622bc16a288e3b4a4ac81338543def00fa4
9 changes: 3 additions & 6 deletions workflow/usage.rst
E968
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ Storing Metadata
----------------

.. versionadded:: 4.1

The feature to store metadata in workflows was introduced in Symfony 4.1.

In case you need it, you can store arbitrary metadata in workflows, their
Expand Down Expand Up @@ -639,9 +640,7 @@ requires:
),
));

Then, you can access this metadata in your PHP code as follows:

In your Controller::
Then you can access this metadata in your controller as follows::

public function myControllerAction(Registry $registry, Article $article)
{
Expand Down Expand Up @@ -676,14 +675,12 @@ There is a shortcut that works with everything::
In a Flash message in your Controller::

// $transition = ...; (an instance of Transition)
// $workflow is a WorkFlow instance retrieved from the Registry (see above)
// $workflow is a Workflow instance retrieved from the Registry (see above)
$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::

<?php

namespace App\Listener\Workflow\Task;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down
0