Skip to content

Commit aea2b64

Browse files
committed
feature #12146 [4.3] Update workflow config (noniagriconomie, wouterj)
This PR was merged into the 4.3 branch. Discussion ---------- [4.3] Update workflow config Rescued some really bad git stuff from me while merging: #11580 Original description: > Hi, > > This draft PR follows this one > https://github.com/symfony/symfony-docs/pull/11492/files (config for 3.X version) > but for new version, mostly 4.3 > > I checked this PR also > symfony/symfony#30890, @lyrixx review appreciated please > > Maybe to merge after merging #11578, and with a rebase ? > > -------------------- > > Draft for now > > - Closes #11229 > > this one can be closed also: > > - Closes #9475 > - Closes #10197 Commits ------- fdc221b Minor XML improvement a640d14 [Workflow] config doc 7bb2041 Fix indent f65f1bc Review cf3a32c Doc config metadata 34e7cc5 [Workflow] config doc
2 parents 11ea0ea + fdc221b commit aea2b64

File tree

5 files changed

+121
-128
lines changed

5 files changed

+121
-128
lines changed

components/workflow.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ Usage
7979
-----
8080

8181
When you have configured a ``Registry`` with your workflows,
82-
you can retrieve a workflow from it and use it as follows::
82+
you can retreive a workflow from it and use it as follows::
8383

8484
// ...
8585
// Consider that $blogPost is in place "draft" by default
86+
// Consider that $post is in state "draft" by default
8687
$blogPost = new BlogPost();
8788
$workflow = $registry->get($blogPost);
8889

reference/configuration/framework.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ Configuration
255255
* :ref:`name <reference-workflows-name>`
256256

257257
* `audit_trail`_
258-
* `initial_place`_
258+
* `initial_marking`_
259259
* `marking_store`_
260+
* `metadata`_
260261
* `places`_
261262
* `supports`_
262263
* `support_strategy`_
@@ -2736,12 +2737,12 @@ audit_trail
27362737
If set to ``true``, the :class:`Symfony\\Component\\Workflow\\EventListener\\AuditTrailListener`
27372738
will be enabled.
27382739

2739-
initial_place
2740-
"""""""""""""
2740+
initial_marking
2741+
"""""""""""""""
27412742

2742-
**type**: ``string`` **default**: ``null``
2743+
**type**: ``string`` | ``array``
27432744

2744-
One of the ``places`` or ``null``. If not null and the supported object is not
2745+
One of the ``places`` or ``empty``. If not null and the supported object is not
27452746
already initialized via the workflow, this place will be set.
27462747

27472748
marking_store
@@ -2753,8 +2754,16 @@ Each marking store can define any of these options:
27532754

27542755
* ``arguments`` (**type**: ``array``)
27552756
* ``service`` (**type**: ``string``)
2756-
* ``type`` (**type**: ``string`` **possible values**: ``'multiple_state'`` or
2757-
``'single_state'``)
2757+
* ``type`` (**type**: ``string`` **allow value**: ``'method'``)
2758+
2759+
metadata
2760+
""""""""
2761+
2762+
**type**: ``array``
2763+
2764+
Metadata available for the workflow configuration.
2765+
Note that ``places`` and ``transitions`` can also have their own
2766+
``metadata`` entry.
27582767

27592768
places
27602769
""""""

workflow.rst

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ like this:
5454
audit_trail:
5555
enabled: true
5656
marking_store:
57-
type: 'multiple_state' # or 'single_state'
58-
arguments:
57+
type: 'method'
58+
property:
5959
- 'currentPlace'
6060
supports:
6161
- App\Entity\BlogPost
62-
initial_place: draft
62+
initial_marking: draft
6363
places:
6464
- draft
6565
- reviewed
@@ -90,35 +90,28 @@ like this:
9090
<framework:config>
9191
<framework:workflow name="blog_publishing" type="workflow">
9292
<framework:audit-trail enabled="true"/>
93-
9493
<framework:marking-store type="single_state">
9594
<framework:argument>currentPlace</framework:argument>
9695
</framework:marking-store>
97-
9896
<framework:support>App\Entity\BlogPost</framework:support>
99-
97+
<framework:initial-marking>draft</framework:initial-marking>
10098
<framework:place>draft</framework:place>
10199
<framework:place>reviewed</framework:place>
102100
<framework:place>rejected</framework:place>
103101
<framework:place>published</framework:place>
104-
105102
<framework:transition name="to_review">
106103
<framework:from>draft</framework:from>
107104
<framework:to>reviewed</framework:to>
108105
</framework:transition>
109-
110106
<framework:transition name="publish">
111107
<framework:from>reviewed</framework:from>
112108
<framework:to>published</framework:to>
113109
</framework:transition>
114-
115110
<framework:transition name="reject">
116111
<framework:from>reviewed</framework:from>
117112
<framework:to>rejected</framework:to>
118113
</framework:transition>
119-
120114
</framework:workflow>
121-
122115
</framework:config>
123116
</container>
124117
@@ -134,10 +127,11 @@ like this:
134127
'enabled' => true
135128
],
136129
'marking_store' => [
137-
'type' => 'multiple_state', // or 'single_state'
138-
'arguments' => ['currentPlace']
130+
'type' => 'method'
131+
'property' => ['currentPlace']
139132
],
140133
'supports' => ['App\Entity\BlogPost'],
134+
'initial_marking' => 'draft',
141135
'places' => [
142136
'draft',
143137
'reviewed',
@@ -177,18 +171,6 @@ As configured, the following property is used by the marking store::
177171
public $content;
178172
}
179173

180-
.. note::
181-
182-
The marking store type could be "multiple_state" or "single_state". A single
183-
state marking store does not support a model being on multiple places at the
184-
same time.
185-
186-
.. tip::
187-
188-
The ``type`` (default value ``single_state``) and ``arguments`` (default
189-
value ``marking``) attributes of the ``marking_store`` option are optional.
190-
If omitted, their default values will be used.
191-
192174
.. tip::
193175

194176
Setting the ``audit_trail.enabled`` option to ``true`` makes the application
@@ -200,7 +182,7 @@ what actions are allowed on a blog post::
200182
use App\Entity\BlogPost;
201183
use Symfony\Component\Workflow\Exception\LogicException;
202184

203-
$post = BlogPost();
185+
$post = new BlogPost();
204186

205187
$workflow = $this->container->get('workflow.blog_publishing');
206188
$workflow->can($post, 'publish'); // False
@@ -630,8 +612,8 @@ requires:
630612
<framework:from>reviewed</framework:from>
631613
<framework:to>published</framework:to>
632614
<framework:metadata>
633-
<framework:hour_limit>20</framework:priority>
634-
<framework:explanation>You can not publish after 8 PM.</framework:priority>
615+
<framework:hour_limit>20</framework:hour_limit>
616+
<framework:explanation>You can not publish after 8 PM.</framework:explanation>
635617
</framework:metadata>
636618
</framework:transition>
637619
</framework:workflow>
@@ -682,6 +664,7 @@ Then you can access this metadata in your controller as follows::
682664

683665
use App\Entity\BlogPost;
684666
use Symfony\Component\Workflow\Registry;
667+
use App\Entity\BlogPost;
685668

686669
public function myController(Registry $registry, BlogPost $post)
687670
{

workflow/dumping-workflows.rst

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -228,63 +228,63 @@ Below is the configuration for the pull request state machine with styling added
228228
// ...
229229
'workflows' => [
230230
'pull_request' => [
231-
'type' => 'state_machine',
232-
'supports' => ['App\Entity\PullRequest'],
233-
'places' => [
234-
'start',
235-
'coding',
236-
'test',
237-
'review' => [
238-
'metadata' => [
239-
'description' => 'Human review',
231+
'type' => 'state_machine',
232+
'supports' => ['App\Entity\PullRequest'],
233+
'places' => [
234+
'start',
235+
'coding',
236+
'test',
237+
'review' => [
238+
'metadata' => [
239+
'description' => 'Human review',
240+
],
240241
],
241-
],
242-
'merged',
243-
'closed' => [
244-
'metadata' => [
245-
'bg_color' => 'DeepSkyBlue',
242+
'merged',
243+
'closed' => [
244+
'metadata' => [
245+
'bg_color' => 'DeepSkyBlue',
246+
],
246247
],
247248
],
248-
],
249-
'transitions' => [
250-
'submit'=> [
251-
'from' => 'start',
252-
'to' => 'test',
253-
],
254-
'update'=> [
255-
'from' => ['coding', 'test', 'review'],
256-
'to' => 'test',
257-
'metadata' => [
258-
'arrow_color' => 'Turquoise',
259-
],
260-
],
261-
'wait_for_review'=> [
262-
'from' => 'test',
263-
'to' => 'review',
264-
'metadata' => [
265-
'color' => 'Orange',
266-
],
267-
],
268-
'request_change'=> [
269-
'from' => 'review',
270-
'to' => 'coding',
271-
],
272-
'accept'=> [
273-
'from' => 'review',
274-
'to' => 'merged',
275-
'metadata' => [
276-
'label' => 'Accept PR',
277-
],
278-
],
279-
'reject'=> [
280-
'from' => 'review',
281-
'to' => 'closed',
282-
],
283-
'reopen'=> [
284-
'from' => 'start',
285-
'to' => 'review',
249+
'transitions' => [
250+
'submit'=> [
251+
'from' => 'start',
252+
'to' => 'test',
253+
],
254+
'update'=> [
255+
'from' => ['coding', 'test', 'review'],
256+
'to' => 'test',
257+
'metadata' => [
258+
'arrow_color' => 'Turquoise',
259+
],
260+
],
261+
'wait_for_review'=> [
262+
'from' => 'test',
263+
'to' => 'review',
264+
'metadata' => [
265+
'color' => 'Orange',
266+
],
267+
],
268+
'request_change'=> [
269+
'from' => 'review',
270+
'to' => 'coding',
271+
],
272+
'accept'=> [
273+
'from' => 'review',
274+
'to' => 'merged',
275+
'metadata' => [
276+
'label' => 'Accept PR',
277+
],
278+
],
279+
'reject'=> [
280+
'from' => 'review',
281+
'to' => 'closed',
282+
],
283+
'reopen'=> [
284+
'from' => 'start',
285+
'to' => 'review',
286+
],
286287
],
287-
],
288288
],
289289
],
290290
]);

workflow/introduction.rst

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Below is the configuration for the pull request state machine.
7979
type: 'state_machine'
8080
supports:
8181
- App\Entity\PullRequest
82-
initial_place: start
82+
initial_marking: start
8383
places:
8484
- start
8585
- coding
@@ -190,46 +190,46 @@ Below is the configuration for the pull request state machine.
190190
// ...
191191
'workflows' => [
192192
'pull_request' => [
193-
'type' => 'state_machine',
194-
'supports' => ['App\Entity\PullRequest'],
195-
'places' => [
196-
'start',
197-
'coding',
198-
'test',
199-
'review',
200-
'merged',
201-
'closed',
202-
],
203-
'transitions' => [
204-
'submit'=> [
205-
'from' => 'start',
206-
'to' => 'test',
193+
'type' => 'state_machine',
194+
'supports' => ['App\Entity\PullRequest'],
195+
'places' => [
196+
'start',
197+
'coding',
198+
'test',
199+
'review',
200+
'merged',
201+
'closed',
207202
],
208-
'update'=> [
209-
'from' => ['coding', 'test', 'review'],
210-
'to' => 'test',
203+
'transitions' => [
204+
'submit'=> [
205+
'from' => 'start',
206+
'to' => 'test',
207+
],
208+
'update'=> [
209+
'from' => ['coding', 'test', 'review'],
210+
'to' => 'test',
211+
],
212+
'wait_for_review'=> [
213+
'from' => 'test',
214+
'to' => 'review',
215+
],
216+
'request_change'=> [
217+
'from' => 'review',
218+
'to' => 'coding',
219+
],
220+
'accept'=> [
221+
'from' => 'review',
222+
'to' => 'merged',
223+
],
224+
'reject'=> [
225+
'from' => 'review',
226+
'to' => 'closed',
227+
],
228+
'reopen'=> [
229+
'from' => 'start',
230+
'to' => 'review',
231+
],
211232
],
212-
'wait_for_review'=> [
213-
'from' => 'test',
214-
'to' => 'review',
215-
],
216-
'request_change'=> [
217-
'from' => 'review',
218-
'to' => 'coding',
219-
],
220-
'accept'=> [
221-
'from' => 'review',
222-
'to' => 'merged',
223-
],
224-
'reject'=> [
225-
'from' => 'review',
226-
'to' => 'closed',
227-
],
228-
'reopen'=> [
229-
'from' => 'start',
230-
'to' => 'review',
231-
],
232-
],
233233
],
234234
],
235235
]);

0 commit comments

Comments
 (0)