From e169f78c6653b2a934a06323484d124474095e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 7 Feb 2023 17:14:13 +0100 Subject: [PATCH] [Workflow] Do not talk about registry This is not recommended since https://github.com/symfony/symfony/pull/46000 --- components/workflow.rst | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/components/workflow.rst b/components/workflow.rst index 67b00730b69..a62491d24b7 100644 --- a/components/workflow.rst +++ b/components/workflow.rst @@ -58,33 +58,12 @@ The ``Workflow`` can now help you to decide what *transitions* (actions) are all on a blog post depending on what *place* (state) it is in. This will keep your domain logic in one place and not spread all over your application. -When you define multiple workflows you should consider using a ``Registry``, -which is an object that stores and provides access to different workflows. -A registry will also help you to decide if a workflow supports the object you -are trying to use it with:: - - use Acme\Entity\BlogPost; - use Acme\Entity\Newsletter; - use Symfony\Component\Workflow\Registry; - use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy; - - $blogPostWorkflow = ...; - $newsletterWorkflow = ...; - - $registry = new Registry(); - $registry->addWorkflow($blogPostWorkflow, new InstanceOfSupportStrategy(BlogPost::class)); - $registry->addWorkflow($newsletterWorkflow, new InstanceOfSupportStrategy(Newsletter::class)); - Usage ----- -When you have configured a ``Registry`` with your workflows, -you can retrieve a workflow from it and use it as follows:: - // ... // Consider that $blogPost is in place "draft" by default $blogPost = new BlogPost(); - $workflow = $registry->get($blogPost); $workflow->can($blogPost, 'publish'); // False $workflow->can($blogPost, 'to_review'); // True @@ -103,7 +82,6 @@ method to initialize the object property:: // ... $blogPost = new BlogPost(); - $workflow = $registry->get($blogPost); // initiate workflow $workflow->getMarking($blogPost);