Skip to content

[Workflow] Fixes the examples related to metadata #12360

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 1 commit into from
Sep 24, 2019
Merged
Changes from all commits
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
20 changes: 15 additions & 5 deletions workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -673,18 +673,28 @@ Then you can access this metadata in your controller as follows::
->getWorkflowMetadata()['title'] ?? 'Default title'
;

// or
$maxNumOfWords = $workflow
->getMetadataStore()
->getPlaceMetadata('draft')['max_num_of_words'] ?? 500
;

$aTransition = $workflow->getDefinition()->getTransitions()[0];
$transitionTitle = $workflow
$priority = $workflow
->getMetadataStore()
->getTransitionMetadata($aTransition)['priority'] ?? 0
;
}

There is a shortcut that works with every metadata level::
There is a ``getMetadata()`` method that works with all kinds of metadata::

// pass no arguments to getMetadata() to get "workflow metadata"
$title = $workflow->getMetadataStore()->getMetadata()['title'];

// pass a string (the place name) to getMetadata() to get "place metadata"
$maxNumOfWords = $workflow->getMetadataStore()->getMetadata('draft')['max_num_of_words'];

$title = $workflow->getMetadataStore()->getMetadata('title');
$priority = $workflow->getMetadataStore()->getMetadata('priority');
// pass a Transition object to getMetadata() to get "transition metadata"
$priority = $workflow->getMetadataStore()->getMetadata($aTransition)['priority'];

In a :ref:`flash message <flash-messages>` in your controller::

Expand Down