Skip to content

Commit 3c94eed

Browse files
committed
[Workflow] Fixes the examples related to metadata
1 parent 1a198b4 commit 3c94eed

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

workflow.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,18 +673,28 @@ Then you can access this metadata in your controller as follows::
673673
->getWorkflowMetadata()['title'] ?? 'Default title'
674674
;
675675

676-
// or
676+
$maxNumOfWords = $workflow
677+
->getMetadataStore()
678+
->getPlaceMetadata('draft')['max_num_of_words'] ?? 500
679+
;
680+
677681
$aTransition = $workflow->getDefinition()->getTransitions()[0];
678-
$transitionTitle = $workflow
682+
$priority = $workflow
679683
->getMetadataStore()
680684
->getTransitionMetadata($aTransition)['priority'] ?? 0
681685
;
682686
}
683687

684-
There is a shortcut that works with every metadata level::
688+
There is a ``getMetadata()`` method that works with all kinds of metadata::
689+
690+
// pass no arguments to getMetadata() to get "workflow metadata"
691+
$title = $workflow->getMetadataStore()->getMetadata()['title'];
692+
693+
// pass a string (the place name) to getMetadata() to get "place metadata"
694+
$maxNumOfWords = $workflow->getMetadataStore()->getMetadata('draft')['max_num_of_words'];
685695

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

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

0 commit comments

Comments
 (0)