Skip to content

Commit d8677e0

Browse files
committed
Merge branch '4.4'
* 4.4: Workflow: explain how to style a workflow dump
2 parents 1f61fee + 70ae64e commit d8677e0

File tree

2 files changed

+240
-0
lines changed

2 files changed

+240
-0
lines changed
Loading

workflow/dumping-workflows.rst

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,245 @@ files and ``PlantUmlDumper`` to create the PlantUML files::
5454
$ php dump-graph.php | dot -Tsvg -o graph.svg
5555
$ php dump-graph.php | java -jar plantuml.jar -p > graph.png
5656
57+
Styling
58+
-------
59+
60+
You can use ``metadata`` with the following keys to style the workflow:
61+
62+
* for places:
63+
* ``bg_color``: a color;
64+
* ``description``: a string that describes the state.
65+
* for transitions:
66+
* ``label``: a string that replaces the name of the transition;
67+
* ``color``: a color;
68+
* ``arrow_color``: a color.
69+
70+
Strings can include ``\n`` characters to display the contents in multiple lines.
71+
Colors can be defined as:
72+
73+
* a color name from `PlantUML's color list`_;
74+
* an hexadecimal color (both ``#AABBCC`` and ``#ABC`` formats are supported).
75+
76+
Below is the configuration for the pull request state machine with styling added.
77+
78+
.. configuration-block::
79+
80+
.. code-block:: yaml
81+
82+
# config/packages/workflow.yaml
83+
framework:
84+
workflows:
85+
pull_request:
86+
type: 'state_machine'
87+
supports:
88+
- App\Entity\PullRequest
89+
initial_place: start
90+
places:
91+
start: ~
92+
coding: ~
93+
test: ~
94+
review:
95+
metadata:
96+
description: Human review
97+
merged: ~
98+
closed:
99+
metadata:
100+
bg_color: DeepSkyBlue
101+
transitions:
102+
submit:
103+
from: start
104+
to: test
105+
update:
106+
from: [coding, test, review]
107+
to: test
108+
metadata:
109+
arrow_color: Turquoise
110+
wait_for_review:
111+
from: test
112+
to: review
113+
metadata:
114+
color: Orange
115+
request_change:
116+
from: review
117+
to: coding
118+
accept:
119+
from: review
120+
to: merged
121+
metadata:
122+
label: Accept PR
123+
reject:
124+
from: review
125+
to: closed
126+
reopen:
127+
from: closed
128+
to: review
129+
130+
.. code-block:: xml
131+
132+
<!-- config/packages/workflow.xml -->
133+
<?xml version="1.0" encoding="UTF-8" ?>
134+
<container xmlns="http://symfony.com/schema/dic/services"
135+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
136+
xmlns:framework="http://symfony.com/schema/dic/symfony"
137+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
138+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
139+
>
140+
141+
<framework:config>
142+
<framework:workflow name="pull_request" type="state_machine">
143+
<framework:marking-store type="single_state"/>
144+
145+
<framework:support>App\Entity\PullRequest</framework:support>
146+
147+
<framework:place>start</framework:place>
148+
<framework:place>coding</framework:place>
149+
<framework:place>test</framework:place>
150+
<framework:place name="review">
151+
<framework:metadata>
152+
<framework:description>Human review</framework:description>
153+
</framework:metadata>
154+
</framework:place>
155+
<framework:place>merged</framework:place>
156+
<framework:place name="closed">
157+
<framework:metadata>
158+
<framework:bg_color>DeepSkyBlue</framework:bg_color>
159+
</framework:metadata>
160+
</framework:place>
161+
</framework:place>
162+
163+
<framework:transition name="submit">
164+
<framework:from>start</framework:from>
165+
166+
<framework:to>test</framework:to>
167+
</framework:transition>
168+
169+
<framework:transition name="update">
170+
<framework:from>coding</framework:from>
171+
<framework:from>test</framework:from>
172+
<framework:from>review</framework:from>
173+
174+
<framework:to>test</framework:to>
175+
176+
<framework:metadata>
177+
<framework:arrow_color>Turquoise</framework:arrow_color>
178+
</framework:metadata>
179+
</framework:transition>
180+
181+
<framework:transition name="wait_for_review">
182+
<framework:from>test</framework:from>
183+
184+
<framework:to>review</framework:to>
185+
186+
<framework:metadata>
187+
<framework:color>Orange</framework:color>
188+
</framework:metadata>
189+
</framework:transition>
190+
191+
<framework:transition name="request_change">
192+
<framework:from>review</framework:from>
193+
194+
<framework:to>coding</framework:to>
195+
</framework:transition>
196+
197+
<framework:transition name="accept">
198+
<framework:from>review</framework:from>
199+
200+
<framework:to>merged</framework:to>
201+
202+
<framework:metadata>
203+
<framework:label>Accept PR</framework:label>
204+
</framework:metadata>
205+
</framework:transition>
206+
207+
<framework:transition name="reject">
208+
<framework:from>review</framework:from>
209+
210+
<framework:to>closed</framework:to>
211+
</framework:transition>
212+
213+
<framework:transition name="reopen">
214+
<framework:from>closed</framework:from>
215+
216+
<framework:to>review</framework:to>
217+
</framework:transition>
218+
219+
</framework:workflow>
220+
221+
</framework:config>
222+
</container>
223+
224+
.. code-block:: php
225+
226+
// config/packages/workflow.php
227+
$container->loadFromExtension('framework', [
228+
// ...
229+
'workflows' => [
230+
'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',
240+
],
241+
],
242+
'merged',
243+
'closed' => [
244+
'metadata' => [
245+
'bg_color' => 'DeepSkyBlue',
246+
],
247+
],
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',
286+
],
287+
],
288+
],
289+
],
290+
]);
291+
292+
The PlantUML image will look like this:
293+
294+
.. image:: /_images/components/workflow/pull_request_puml_styled.png
295+
57296
.. _`Graphviz`: http://www.graphviz.org
58297
.. _`PlantUML`: http://plantuml.com/
298+
.. _`PlantUML's color list`: http://plantuml.com/en/color

0 commit comments

Comments
 (0)