8000 Added docs for workflow_marked_places() function by javiereguiluz · Pull Request #7820 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Added docs for workflow_marked_places() function #7820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions workflow/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,26 @@ This class has two more methods:
Usage in Twig
-------------

Using your workflow in your Twig templates reduces the need of domain logic
in the view layer. Consider this example of the control panel of the blog.
The links below will only be displayed when the action is allowed:
Symfony defines several Twig functions to manage workflows and reduce the need
of domain logic in your templates:

``workflow_can()``
Returns ``true`` if the given object can make the given transition.

``workflow_transitions()``
Returns an array with all the transitions enabled for the given object.

``workflow_marked_places()``
Returns an array with the place names of the given marking.

``workflow_has_marked_place()``
Returns ``true`` if the marking of the given object has the given state.

.. versionadded:: 3.3
The ``workflow_marked_places()`` and ``workflow_has_marked_place()``
functions were introduced in Symfony 3.3.

The following example shows these functions in action:

.. code-block:: twig

Expand All @@ -277,3 +294,8 @@ The links below will only be displayed when the action is allowed:
{% if workflow_has_marked_place(post, 'to_review') %}
<p>This post is ready for review.</p>
{% endif %}

{# Check if some place has been marked on the object #}
{% if 'waiting_some_approval' in workflow_marked_places(post) %}
<span class="label">PENDING</span>
{% endif %}
0