@@ -58,33 +58,12 @@ The ``Workflow`` can now help you to decide what *transitions* (actions) are all
58
58
on a blog post depending on what *place * (state) it is in. This will keep your domain
59
59
logic in one place and not spread all over your application.
60
60
61
- When you define multiple workflows you should consider using a ``Registry ``,
62
- which is an object that stores and provides access to different workflows.
63
- A registry will also help you to decide if a workflow supports the object you
64
- are trying to use it with::
65
-
66
- use Acme\Entity\BlogPost;
67
- use Acme\Entity\Newsletter;
68
- use Symfony\Component\Workflow\Registry;
69
- use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
70
-
71
- $blogPostWorkflow = ...;
72
- $newsletterWorkflow = ...;
73
-
74
- $registry = new Registry();
75
- $registry->addWorkflow($blogPostWorkflow, new InstanceOfSupportStrategy(BlogPost::class));
76
- $registry->addWorkflow($newsletterWorkflow, new InstanceOfSupportStrategy(Newsletter::class));
77
-
78
61
Usage
79
62
-----
80
63
81
- When you have configured a ``Registry `` with your workflows,
82
- you can retrieve a workflow from it and use it as follows::
83
-
84
64
// ...
85
65
// Consider that $blogPost is in place "draft" by default
86
66
$blogPost = new BlogPost();
87
- $workflow = $registry->get($blogPost);
88
67
89
68
$workflow->can($blogPost, 'publish'); // False
90
69
$workflow->can($blogPost, 'to_review'); // True
@@ -103,7 +82,6 @@ method to initialize the object property::
103
82
104
83
// ...
105
84
$blogPost = new BlogPost();
106
- $workflow = $registry->get($blogPost);
107
85
108
86
// initiate workflow
109
87
$workflow->getMarking($blogPost);
0 commit comments