Skip to content

Commit 018b64c

Browse files
committed
added the usage of workflow injection
1 parent f9afb77 commit 018b64c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

workflow.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -858,25 +858,23 @@ Then you can access this metadata in your controller as follows::
858858

859859
// src/App/Controller/BlogPostController.php
860860
use App\Entity\BlogPost;
861-
use Symfony\Component\Workflow\Registry;
861+
use Symfony\Component\Workflow\WorkflowInterface;
862862
// ...
863863

864-
public function myAction(Registry $registry, BlogPost $post)
864+
public function myAction(WorkflowInterface $blogPostWorkflow, BlogPost $post)
865865
{
866-
$workflow = $registry->get($post);
867-
868-
$title = $workflow
866+
$title = $blogPostWorkflow
869867
->getMetadataStore()
870868
->getWorkflowMetadata()['title'] ?? 'Default title'
871869
;
872870

873-
$maxNumOfWords = $workflow
871+
$maxNumOfWords = $blogPostWorkflow
874872
->getMetadataStore()
875873
->getPlaceMetadata('draft')['max_num_of_words'] ?? 500
876874
;
877875

878-
$aTransition = $workflow->getDefinition()->getTransitions()[0];
879-
$priority = $workflow
876+
$aTransition = $blogPostWorkflow->getDefinition()->getTransitions()[0];
877+
$priority = $blogPostWorkflow
880878
->getMetadataStore()
881879
->getTransitionMetadata($aTransition)['priority'] ?? 0
882880
;

0 commit comments

Comments
 (0)