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 740f95b

Browse filesBrowse files
committed
feature symfony#7820 Added docs for workflow_marked_places() function (javiereguiluz)
This PR was squashed before being merged into the master branch (closes symfony#7820). Discussion ---------- Added docs for workflow_marked_places() function This fixes symfony#7785. Commits ------- 09983c5 Added docs for workflow_marked_places() function
2 parents 97faaef + 09983c5 commit 740f95b
Copy full SHA for 740f95b

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
@@ -255,9 +255,26 @@ This class has two more methods:
255255
Usage in Twig
256256
-------------
257257

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

262279
.. code-block:: twig
263280
@@ -283,3 +300,8 @@ The links below will only be displayed when the action is allowed:
283300
{% if workflow_has_marked_place(post, 'to_review') %}
284301
<p>This post is ready for review.</p>
285302
{% endif %}
303+
304+
{# Check if some place has been marked on the object #}
305+
{% if 'waiting_some_approval' in workflow_marked_places(post) %}
306+
<span class="label">PENDING</span>
307+
{% endif %}

0 commit comments

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