@@ -85,41 +85,6 @@ method to initialize the object property::
85
85
// initiate workflow
86
86
$workflow->getMarking($blogPost);
87
87
88
- Using The Workflow Registry
89
- ---------------------------
90
-
91
- When you define multiple workflows you may consider using a ``Registry ``,
92
- which is an object that stores and provides access to different workflows.
93
- A registry will also help you to decide if a workflow supports the object you
94
- are trying to use it with::
95
-
96
- use Acme\Entity\BlogPost;
97
- use Acme\Entity\Newsletter;
98
- use Symfony\Component\Workflow\Registry;
99
- use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
100
-
101
- $blogPostWorkflow = ...;
102
- $newsletterWorkflow = ...;
103
-
104
- $registry = new Registry();
105
- $registry->addWorkflow($blogPostWorkflow, new InstanceOfSupportStrategy(BlogPost::class));
106
- $registry->addWorkflow($newsletterWorkflow, new InstanceOfSupportStrategy(Newsletter::class));
107
-
108
- You can then use the registry to get the workflow for a specific object::
109
-
110
- $blogPost = new BlogPost();
111
- $workflow = $registry->get($blogPost);
112
-
113
- // initiate workflow
114
- $workflow->getMarking($blogPost);
115
-
116
- .. caution ::
117
-
118
- Beware that injecting the ``Registry `` into your services is **not **
119
- recommended. Indeed, it prevents some optimization like lazy-loading
120
- from working and could be a performance hog. Instead, you should always
121
- inject the workflow you need.
122
-
123
88
Learn more
124
89
----------
125
90
0 commit comments