From e74049301e26257cf80f3cc675a8551ba78461ae Mon Sep 17 00:00:00 2001
From: Javier Eguiluz
Date: Fri, 23 Mar 2018 16:44:23 +0100
Subject: [PATCH] Documented the workflow metadata
---
workflow/usage.rst | 142 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 142 insertions(+)
diff --git a/workflow/usage.rst b/workflow/usage.rst
index 2126a61d701..e6ce666c2b7 100644
--- a/workflow/usage.rst
+++ b/workflow/usage.rst
@@ -450,3 +450,145 @@ The following example shows these functions in action:
{% if 'waiting_some_approval' in workflow_marked_places(post) %}
PENDING
{% endif %}
+
+Storing Metadata
+----------------
+
+.. versionadded:: 4.1
+ The feature to store metadata in workflows was introduced in Symfony 4.1.
+
+In case you need it, you can store arbitrary metadata in workflows, their
+places, and their transitions using the ``metadata`` option. This metadata can
+be as simple as the title of the workflow or as complex as your own application
+requires:
+
+.. configuration-block::
+
+ .. code-block:: yaml
+
+ # config/packages/workflow.yaml
+ framework:
+ workflows:
+ blog_publishing:
+ metadata: 'Blog Publishing Workflow'
+ # ...
+ places:
+ draft:
+ metadata:
+ max_num_of_words: 500
+ # ...
+ transitions:
+ to_review:
+ from: draft
+ to: review
+ metadata:
+ priority: 0.5
+ # ...
+
+ .. code-block:: xml
+
+
+
+
+
+
+
+
+ Blog Publishing Workflow
+
+
+
+
+
+ 500
+
+
+
+
+
+ draft
+ review
+
+ 0.5
+
+
+
+
+
+
+
+ .. code-block:: php
+
+ // config/packages/workflow.php
+
+ $container->loadFromExtension('framework', array(
+ // ...
+ 'workflows' => array(
+ 'blog_publishing' => array(
+ 'metadata' => array(
+ 'title' => 'Blog Publishing Workflow',
+ ),
+ // ...
+ 'places' => array(
+ 'draft' => array(
+ 'max_num_of_words' => 500,
+ ),
+ // ...
+ ),
+ 'transitions' => array(
+ 'to_review' => array(
+ 'from' => 'draft',
+ 'to' => 'review',
+ 'metadata' => array(
+ 'priority' => 0.5,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ));
+
+Then, you can access this metadata in your PHP code as follows::
+
+ // MISSING EXAMPLE HERE...
+ //
+ //
+ //
+ //
+
+In Twig templates, metadata is available via the ``workflow_metadata()`` function:
+
+.. code-block:: twig
+
+ Metadata
+
+ Workflow:
+ {{ workflow_metadata(article, 'title') }}
+
+
+ Current place(s)
+
+ {% for place in workflow_marked_places(article) %}
+ -
+ {{ place }}:
+
{{ workflow_metadata(article, 'max_num_of_words', place) ?: 'Unlimited'}}
+
+ {% endfor %}
+
+
+
+ Enabled transition(s)
+
+ {% for transition in workflow_transitions(article) %}
+ -
+ {{ transition.name }}:
+
{{ workflow_metadata(article, 'priority', transition) ?: '0' }}
+
+ {% endfor %}
+
+
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy