Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 09983c5

Browse filesBrowse files
javiereguiluzxabbuh
authored andcommitted
Added docs for workflow_marked_places() function
1 parent 2b1dbee commit 09983c5
Copy full SHA for 09983c5

File tree

Expand file treeCollapse file tree

1 file changed

+25
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-3
lines changed

‎workflow/usage.rst

Copy file name to clipboardExpand all lines: workflow/usage.rst
+25-3Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,26 @@ This class has two more methods:
249249
Usage in Twig
250250
-------------
251251

252-
Using your workflow in your Twig templates reduces the need of domain logic
253-
in the view layer. Consider this example of the control panel of the blog.
254-
The links below will only be displayed when the action is allowed:
252+
Symfony defines several Twig functions to manage workflows and reduce the need
253+
of domain logic in your templates:
254+
255+
``workflow_can()``
256+
Returns ``true`` if the given object can make the given transition.
257+
258+
``workflow_transitions()``
259+
Returns an array with all the transitions enabled for the given object.
260+
261+
``workflow_marked_places()``
262+
Returns an array with the place names of the given marking.
263+
264+
``workflow_has_marked_place()``
265+
Returns ``true`` if the marking of the given object has the given state.
266+
267+
.. versionadded:: 3.3
268+
The ``workflow_marked_places()`` and ``workflow_has_marked_place()``
269+
functions were introduced in Symfony 3.3.
270+
271+
The following example shows these functions in action:
255272

256273
.. code-block:: twig
257274
@@ -277,3 +294,8 @@ The links below will only be displayed when the action is allowed:
277294
{% if workflow_has_marked_place(post, 'to_review') %}
278295
<p>This post is ready for review.</p>
279296
{% endif %}
297+
298+
{# Check if some place has been marked on the object #}
299+
{% if 'waiting_some_approval' in workflow_marked_places(post) %}
300+
<span class="label">PENDING</span>
301+
{% endif %}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.