File tree 1 file changed +25
-3
lines changed
1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -249,9 +249,26 @@ This class has two more methods:
249
249
Usage in Twig
250
250
-------------
251
251
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:
255
272
256
273
.. code-block :: twig
257
274
@@ -277,3 +294,8 @@ The links below will only be displayed when the action is allowed:
277
294
{% if workflow_has_marked_place(post, 'to_review') %}
278
295
<p>This post is ready for review.</p>
279
296
{% 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 %}
You can’t perform that action at this time.
0 commit comments