Norway


In Symfony 4.1 we improved the Workflow component with lots of and
minor features. This post summarizes the most important ones.


Sébastien Morel  - 217af464 4b94 4497 b01c ad1210d2fd7f - New in Symfony 4.1: Workflow improvements (Symfony Blog)

Workflows can already be exported to the well-known DOT format and then
transformed into image files. In Symfony 4.1 we added support for other popular
format called PlantUML. So now you can the format that best suits you:

# traditional DOT-based dumping
$ bin/console :dump my_ | dot -Tpng > my_workflow.png

# new PlantUML-based dumping
$ bin/console workflow:dump my_workflow --dump-format=puml | java -jar plantuml.jar -p > my_workflow.png

Grégoire Pineau  - 7602f2751868682b296171f58589c851 - New in Symfony 4.1: Workflow improvements (Symfony Blog)

Previously the names of the workflow transitions and places could only contain
the characters that matched this regular expression: [w_-]. Now you can use
any character in those names.


Hamza Amrouche  - 3451634 - New in Symfony 4.1: Workflow improvements (Symfony Blog)

The Workflow class now implements the new WorkflowInterface. This interface
contains the same methods of the existing class (getMarking(), can(),
apply(), getEnabledTransitions(), getName(), getDefinition()
and getMarkingStore()) so you don’t have to make any in your code.

In addition, a new WorkflowSupportStrategyInterface has been created to
replace the now deprecated SupportStrategyInterface. The new interface only
contains the supports() method, so again you don’t need to change anything
in your code except the interface class.


Grégoire Pineau  - 7602f2751868682b296171f58589c851 - New in Symfony 4.1: Workflow improvements (Symfony Blog)

The new transition blockers defined via the TransitionBlocker class allow
you to give more information about why a transition couldn’t happen in the
workflow:

$event->addTransitionBlocker(
    new TransitionBlocker('You can not publish this article because it's too late. Try again tomorrow morning.')
);

And then you can access to this information in PHP code and Twig templates too:

 1
 2
 3
 4
 5
 6
 7
 8
 9

11

13
14
15
16
17
18
19
20
<h2>Why you can't transition?</h2>
<ul>
    {% for transition in workflow_all_transitions(article) %}
        {% if not workflow_can(article, transition.name) %}
            <li>
                <strong>{{ transition.name }}</strong>:
                <ul>
                {% for blocker in workflow_build_transition_blocker_list(article, transition.name) %}
                    <li>
                        {{ blocker.message }}
                        {% if blocker.parameters.expression is defined %}
                            <code>{{ blocker.parameters.expression }}</code>
                        {% endif %}
                    </li>
                {% endfor %}
                </ul>
            </li>
        {% endif %}
    {% endfor %}
</ul>

Andrew Tchircoff  - 69eb67bf 8454 4198 80dc bab296e5bde0 - New in Symfony 4.1: Workflow improvements (Symfony Blog)

When a transition cannot be applied for the workflow, a new
SymfonyComponentWorkflowExceptionTransitionException is thrown instead
of the previous generic LogicException.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here