From 9657a568e01bd864887e8bad6e5c4229e837c55f Mon Sep 17 00:00:00 2001 From: carherco Date: Tue, 23 Apr 2019 16:00:30 +0200 Subject: [PATCH 1/3] Fixing retrieving metadata examples There was no example about retrieving place metadata from the controller. I tried to fixed it as well as the example of retrieving transition metadata. Don't know wether the code I propose is correct. It would need a revision from anybody who knows how it works. --- workflow.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/workflow.rst b/workflow.rst index bb15af35ba7..bad7e3f4858 100644 --- a/workflow.rst +++ b/workflow.rst @@ -612,21 +612,24 @@ Then you can access this metadata in your controller as follows:: ; // or - $title = $workflow->getMetadataStore() - ->getWorkflowMetadata()['title'] ?? false + $max_num_of_words = $workflow->getMetadataStore() + ->getPlaceMetadata('draft')['max_num_of_words'] ?? false ; // or $aTransition = $workflow->getDefinition()->getTransitions()[0]; - $transitionTitle = $workflow + $priority = $workflow ->getMetadataStore() - ->getTransitionMetadata($aTransition)['title'] ?? false + ->getTransitionMetadata($aTransition)['priority'] ?? false ; } There is a shortcut that works with everything:: - $title = $workflow->getMetadataStore()->getMetadata('title'); + $title = $workflow->getMetadataStore()->getMetadata()['title']; + $max_num_of_words = $workflow->getMetadataStore()->getMetadata('draft')['max_num_of_words']; + $priority = $workflow->getMetadataStore()->getMetadata($aTransition)['priority']; + In a :ref:`flash message ` in your controller:: From e4aa3b6756c093af7c115ddd25e3e76895a8a64b Mon Sep 17 00:00:00 2001 From: carherco Date: Tue, 23 Apr 2019 16:44:25 +0200 Subject: [PATCH 2/3] Name of PHP variables in camel case The array key comes from configuration in line 528 --- workflow.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow.rst b/workflow.rst index bad7e3f4858..d1b2649a3d6 100644 --- a/workflow.rst +++ b/workflow.rst @@ -612,7 +612,7 @@ Then you can access this metadata in your controller as follows:: ; // or - $max_num_of_words = $workflow->getMetadataStore() + $maxNumOfWords = $workflow->getMetadataStore() ->getPlaceMetadata('draft')['max_num_of_words'] ?? false ; @@ -627,7 +627,7 @@ Then you can access this metadata in your controller as follows:: There is a shortcut that works with everything:: $title = $workflow->getMetadataStore()->getMetadata()['title']; - $max_num_of_words = $workflow->getMetadataStore()->getMetadata('draft')['max_num_of_words']; + $maxNumOfWords = $workflow->getMetadataStore()->getMetadata('draft')['max_num_of_words']; $priority = $workflow->getMetadataStore()->getMetadata($aTransition)['priority']; From 578b543c5dc6d93ab261e8439163c7cbba49e66e Mon Sep 17 00:00:00 2001 From: carherco Date: Tue, 21 May 2019 11:15:58 +0200 Subject: [PATCH 3/3] Update workflow.rst default value of priority and max_num_of_words are now numbers --- workflow.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow.rst b/workflow.rst index d1b2649a3d6..571a8f25917 100644 --- a/workflow.rst +++ b/workflow.rst @@ -613,14 +613,14 @@ Then you can access this metadata in your controller as follows:: // or $maxNumOfWords = $workflow->getMetadataStore() - ->getPlaceMetadata('draft')['max_num_of_words'] ?? false + ->getPlaceMetadata('draft')['max_num_of_words'] ?? 500 ; // or $aTransition = $workflow->getDefinition()->getTransitions()[0]; $priority = $workflow ->getMetadataStore() - ->getTransitionMetadata($aTransition)['priority'] ?? false + ->getTransitionMetadata($aTransition)['priority'] ?? 0.5 ; }