Skip to content

Commit ac83517

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: [Workflow] Update the article about dumping workflows Added a short guide to help creating the Symfony diagrams
2 parents 657e996 + f9f806d commit ac83517

File tree

4 files changed

+93
-43
lines changed

4 files changed

+93
-43
lines changed

_images/sources/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
How to Create Symfony Diagrams
2+
==============================
3+
4+
Creating the Diagram
5+
--------------------
6+
7+
* Use [Dia][1] as the diagramming application;
8+
* Use [PT Sans Narrow][2] as the only font in all diagrams (if possible, use
9+
only the "normal" weight for all contents);
10+
* Use 36pt as the base font size;
11+
* Use 0.10 cm width for lines and shape borders;
12+
* Use the following color palette:
13+
* Text, lines and shape borders: black (#000000)
14+
* Shape backgrounds:
15+
* Grays: dark (#4d4d4d), medium (#b3b3b3), light (#f2f2f2)
16+
* Blue: #b2d4eb
17+
* Red: #ecbec0
18+
* Green: #b2dec7
19+
* Orange: #fddfbb
20+
21+
In case of doubt, check the existing diagrams or ask to the
22+
[Symfony Documentation Team][3].
23+
24+
Saving and Exporting the Diagram
25+
--------------------------------
26+
27+
* Save the original diagram in `*.dia` format in `_images/sources/<folder-name>`;
28+
* Export the diagram to SVG format and save it in `_images/<folder-name>`.
29+
30+
Including the Diagram in the Symfony Docs
31+
-----------------------------------------
32+
33+
Use the following snippet to embed the diagram in the docs:
34+
35+
```
36+
.. raw:: html
37+
38+
<object data="../_images/<folder-name>/<diagram-file-name>.svg" type="image/svg+xml"></object>
39+
```
40+
41+
Reasoning
42+
---------
43+
44+
* Dia was chosen because it's one of the few applications which are free, open
45+
source and compatible with Linux, macOS and Windows.
46+
* Font, colors and line widths were chosen to be similar to the diagrams used
47+
in the best tech books.
48+
49+
Troubleshooting
50+
---------------
51+
52+
* On some macOS systems, Dia cannot be executed as a regular application and
53+
you must run the following console command instead:
54+
`export DISPLAY=:0 && /Applications/Dia.app/Contents/Resources/bin/dia`
55+
56+
[1]: http://dia-installer.de/
57+
[2]: https://fonts.google.com/specimen/PT+Sans+Narrow
58+
[3]: https://symfony.com/doc/current/contributing/code/core_team.html

reference/forms/types/options/checkbox_empty_data.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ empty_data
55

66
This option determines what value the field will return when the ``placeholder``
77
choice is selected. In the checkbox and the radio type, the value of ``empty_data``
8-
is overriden by the value returned by the data transformer (see :doc:`/form/data_transformers`).
8+
is overridden by the value returned by the data transformer (see :doc:`/form/data_transformers`).

reference/forms/types/options/data.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ an individual field, you can set it in the data option::
1919
.. caution::
2020

2121
The ``data`` option *always* overrides the value taken from the domain data
22-
(object) when rendering. This means the object value is also overriden when
22+
(object) when rendering. This means the object value is also overridden when
2323
the form edits an already persisted object, causing it to lose its
2424
persisted value when the form is submitted.

workflow/dumping-workflows.rst

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,55 @@
44
How to Dump Workflows
55
=====================
66

7-
To help you debug your workflows, you can dump a representation of your workflow
8-
or state machine with the use of a ``DumperInterface``. Symfony provides two
9-
different dumpers, both based on Dot (see below).
7+
To help you debug your workflows, you can generate a visual representation of
8+
them as SVG or PNG images. First, install any of these free and open source
9+
applications needed to generate the images:
1010

11-
Use the ``GraphvizDumper`` or ``StateMachineGraphvizDumper`` to create DOT
12-
files, or use ``PlantUmlDumper`` for PlantUML files. Both types can be converted
13-
to PNG or SVG images.
11+
* `Graphviz`_, provides the ``dot`` command;
12+
* `PlantUML`_, provides the ``plantuml.jar`` file (which requires Java).
1413

15-
Images of the workflow defined above::
16-
17-
// dump-graph-dot.php
18-
$dumper = new GraphvizDumper();
19-
echo $dumper->dump($definition);
20-
21-
// dump-graph-puml.php
22-
$dumper = new PlantUmlDumper();
23-
echo $dumper->dump($definition);
14+
If you are defining the workflow inside a Symfony application, run this command
15+
to dump it as an image:
2416

2517
.. code-block:: terminal
2618
27-
# dump DOT file in PNG image:
28-
$ php dump-graph-dot.php | dot -Tpng -o dot_graph.png
19+
# using Graphviz's 'dot' and SVG images
20+
$ php bin/console workflow:dump workflow-name | dot -Tsvg -o graph.svg
21+
22+
# using Graphviz's 'dot' and PNG images
23+
$ php bin/console workflow:dump workflow-name | dot -Tpng -o graph.png
2924
30-
# dump DOT file in SVG image:
31-
# $ php dump-graph-dot.php | dot -Tsvg -o dot_graph.svg
25+
# using PlantUML's 'plantuml.jar'
26+
$ php bin/console workflow:dump workflow_name --dump-format=puml | java -jar plantuml.jar -p > graph.png
3227
33-
# dump PlantUML in PNG image:
34-
$ php dump-graph-puml.php | java -jar plantuml.jar -p > puml_graph.png
28+
# highlight 'place1' and 'place2' in the dumped workflow
29+
$ php bin/console workflow:dump workflow-name place1 place2 | dot -Tsvg -o graph.svg
3530
36-
The DOT result will look like this:
31+
The DOT image will look like this:
3732

3833
.. image:: /_images/components/workflow/blogpost.png
3934

40-
The PlantUML result:
35+
The PlantUML image will look like this:
4136

4237
.. image:: /_images/components/workflow/blogpost_puml.png
4338

44-
Inside a Symfony application, you can dump the files with those commands using
45-
``workflow:dump`` command:
39+
If you are creating workflows outside of a Symfony application, use the
40+
``GraphvizDumper`` or ``StateMachineGraphvizDumper`` class to create the DOT
41+
files and ``PlantUmlDumper`` to create the PlantUML files::
4642

47-
.. code-block:: terminal
48-
49-
$ php bin/console workflow:dump workflow_name | dot -Tpng -o workflow_name.png
50-
$ php bin/console workflow:dump workflow_name | dot -Tsvg -o workflow_name.svg
51-
$ php bin/console workflow:dump workflow_name --dump-format=puml | java -jar plantuml.jar -p > workflow_name.png
52-
53-
# highlight 'place1' and 'place2' in the dumped workflow
54-
$ php bin/console workflow:dump name place1 place2 | dot -Tsvg -o graph.svg
55-
56-
.. note::
43+
// Add this code to a PHP script; for example: dump-graph.php
44+
$dumper = new GraphvizDumper();
45+
echo $dumper->dump($definition);
5746

58-
The ``dot`` command is part of Graphviz. You can download it and read
59-
more about it on `Graphviz.org`_.
47+
# if you prefer PlantUML, use this code:
48+
# $dumper = new PlantUmlDumper();
49+
# echo $dumper->dump($definition);
6050

61-
The ``plantuml.jar`` command is part of PlantUML. You can download it and
62-
read more about it on `PlantUML.com`_.
51+
.. code-block:: terminal
6352
53+
# replace 'dump-graph.php' by the name of your PHP script
54+
$ php dump-graph.php | dot -Tsvg -o graph.svg
55+
$ php dump-graph.php | java -jar plantuml.jar -p > graph.png
6456
65-
.. _Graphviz.org: http://www.graphviz.org
66-
.. _PlantUML.com: http://plantuml.com/
57+
.. _`Graphviz`: http://www.graphviz.org
58+
.. _`PlantUML`: http://plantuml.com/

0 commit comments

Comments
 (0)