Skip to content

Commit a2281d2

Browse files
committed
[Workflow] Do to talk about workflow, and explain what support option is for
1 parent 319b504 commit a2281d2

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

components/workflow.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,6 @@ The ``Workflow`` can now help you to decide what *transitions* (actions) are all
5555
on a blog post depending on what *place* (state) it is in. This will keep your domain
5656
logic in one place and not spread all over your application.
5757

58-
When you define multiple workflows you should consider using a ``Registry``,
59-
which is an object that stores and provides access to different workflows.
60-
A registry will also help you to decide if a workflow supports the object you
61-
are trying to use it with::
62-
63-
use Acme\Entity\BlogPost;
64-
use Acme\Entity\Newsletter;
65-
use Symfony\Component\Workflow\Registry;
66-
use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
67-
68-
$blogPostWorkflow = ...;
69-
$newsletterWorkflow = ...;
70-
71-
$registry = new Registry();
72-
$registry->addWorkflow($blogPostWorkflow, new InstanceOfSupportStrategy(BlogPost::class));
73-
$registry->addWorkflow($newsletterWorkflow, new InstanceOfSupportStrategy(Newsletter::class));
74-
7558
Usage
7659
-----
7760

@@ -100,7 +83,6 @@ method to initialize the object property::
10083

10184
// ...
10285
$blogPost = new BlogPost();
103-
$workflow = $registry->get($blogPost);
10486

10587
// initiate workflow
10688
$workflow->getMarking($blogPost);

workflow/workflow-and-state-machine.rst

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Below is the configuration for the pull request state machine.
8181
marking_store:
8282
type: 'method'
8383
property: 'currentPlace'
84+
# The supports options is useful only if you are using twig functions ('workflow_*')
8485
supports:
8586
- App\Entity\PullRequest
8687
initial_marking: start
@@ -132,6 +133,7 @@ Below is the configuration for the pull request state machine.
132133
<framework:property>currentPlace</framework:property>
133134
</framework:marking-store>
134135
136+
<!-- The supports options is useful only if you are using twig functions ('workflow_*') -->
135137
<framework:support>App\Entity\PullRequest</framework:support>
136138
137139
<framework:initial_marking>start</framework:initial_marking>
@@ -202,6 +204,7 @@ Below is the configuration for the pull request state machine.
202204
203205
$pullRequest
204206
->type('state_machine')
207+
// The supports options is useful only if you are using twig functions ('workflow_*')
205208
->supports(['App\Entity\PullRequest'])
206209
->initialMarking(['start']);
207210
@@ -252,33 +255,6 @@ Below is the configuration for the pull request state machine.
252255
->to(['review']);
253256
};
254257
255-
In a Symfony application using the
256-
:ref:`default services.yaml configuration <service-container-services-load-example>`,
257-
you can get this state machine by injecting the Workflow registry service::
258-
259-
// ...
260-
use App\Entity\PullRequest;
261-
use Symfony\Component\Workflow\Registry;
262-
263-
class SomeService
264-
{
265-
private $workflows;
266-
267-
public function __construct(Registry $workflows)
268-
{
269-
$this->workflows = $workflows;
270-
}
271-
272-
public function someMethod(PullRequest $pullRequest)
273-
{
274-
$stateMachine = $this->workflows->get($pullRequest, 'pull_request');
275-
$stateMachine->apply($pullRequest, 'wait_for_review');
276-
// ...
277-
}
278-
279-
// ...
280-
}
281-
282258
Symfony automatically creates a service for each workflow (:class:`Symfony\\Component\\Workflow\\Workflow`)
283259
or state machine (:class:`Symfony\\Component\\Workflow\\StateMachine`) you
284260
have defined in your configuration. This means that you can use ``workflow.pull_request``

0 commit comments

Comments
 (0)