Skip to content

Fixing retrieving metadata examples #11473

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

Closed
wants to merge 4 commits into from
Closed
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
22 changes: 18 additions & 4 deletions workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -692,18 +692,32 @@ 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
;

// or
$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 shortcut that works with every metadata level. With this shortcut:

* Use null to get workflow metadata
* Use a string (the place name) to get place metadata
* Use a Transition instance to get transition metadata

Example::

$title = $workflow->getMetadataStore()->getMetadata()['title'];
$maxNumOfWords = $workflow->getMetadataStore()->getMetadata('draft')['max_num_of_words'];
$priority = $workflow->getMetadataStore()->getMetadata($aTransition)['priority'];

$title = $workflow->getMetadataStore()->getMetadata('title');
$priority = $workflow->getMetadataStore()->getMetadata('priority');

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

Expand Down