From 34e7cc52d88b8bd830eb098b3301fa303d7d2cb4 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 16 May 2019 19:10:03 +0200 Subject: [PATCH 1/6] [Workflow] config doc --- reference/configuration/framework.rst | 13 ++++++------- workflow.rst | 22 +++++----------------- workflow/introduction.rst | 2 +- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index c03cc8500c7..8bceae41cf8 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -255,7 +255,7 @@ Configuration * :ref:`name ` * `audit_trail`_ - * `initial_place`_ + * `initial_marking`_ * `marking_store`_ * `places`_ * `supports`_ @@ -2736,12 +2736,12 @@ audit_trail If set to ``true``, the :class:`Symfony\\Component\\Workflow\\EventListener\\AuditTrailListener` will be enabled. -initial_place -""""""""""""" +initial_marking +""""""""""""""" -**type**: ``string`` **default**: ``null`` +**type**: ``string`` | ``array`` -One of the ``places`` or ``null``. If not null and the supported object is not +One of the ``places`` or ``empty``. If not null and the supported object is not already initialized via the workflow, this place will be set. marking_store @@ -2753,8 +2753,7 @@ Each marking store can define any of these options: * ``arguments`` (**type**: ``array``) * ``service`` (**type**: ``string``) -* ``type`` (**type**: ``string`` **possible values**: ``'multiple_state'`` or - ``'single_state'``) +* ``type`` (**type**: ``string`` **allow value**: ``'method'``) places """""" diff --git a/workflow.rst b/workflow.rst index cf1a5802036..b668e6f5fa0 100644 --- a/workflow.rst +++ b/workflow.rst @@ -54,12 +54,12 @@ like this: audit_trail: enabled: true marking_store: - type: 'multiple_state' # or 'single_state' - arguments: + type: 'method' + property: - 'currentPlace' supports: - App\Entity\BlogPost - initial_place: draft + initial_marking: draft places: - draft - reviewed @@ -134,8 +134,8 @@ like this: 'enabled' => true ], 'marking_store' => [ - 'type' => 'multiple_state', // or 'single_state' - 'arguments' => ['currentPlace'] + 'type' => 'method' + 'property' => ['currentPlace'] ], 'supports' => ['App\Entity\BlogPost'], 'places' => [ @@ -177,18 +177,6 @@ As configured, the following property is used by the marking store:: public $content; } -.. note:: - - The marking store type could be "multiple_state" or "single_state". A single - state marking store does not support a model being on multiple places at the - same time. - -.. tip:: - - The ``type`` (default value ``single_state``) and ``arguments`` (default - value ``marking``) attributes of the ``marking_store`` option are optional. - If omitted, their default values will be used. - .. tip:: Setting the ``audit_trail.enabled`` option to ``true`` makes the application diff --git a/workflow/introduction.rst b/workflow/introduction.rst index c8302870ac1..0b146164f03 100644 --- a/workflow/introduction.rst +++ b/workflow/introduction.rst @@ -79,7 +79,7 @@ Below is the configuration for the pull request state machine. type: 'state_machine' supports: - App\Entity\PullRequest - initial_place: start + initial_marking: start places: - start - coding From cf3a32c5f7269e49cca4b9da06178522b11debc9 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 20 May 2019 09:31:23 +0200 Subject: [PATCH 2/6] Doc config metadata --- reference/configuration/framework.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 8bceae41cf8..08f55dcf2a7 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -257,6 +257,7 @@ Configuration * `audit_trail`_ * `initial_marking`_ * `marking_store`_ + * `metadata`_ * `places`_ * `supports`_ * `support_strategy`_ @@ -2755,6 +2756,15 @@ Each marking store can define any of these options: * ``service`` (**type**: ``string``) * ``type`` (**type**: ``string`` **allow value**: ``'method'``) +metadata +"""""""" + +**type**: ``array`` + +Metadata available for the workflow configuration. +Note that ``places`` and ``transitions`` can also have their own +``metadata`` entry. + places """""" From f65f1bcad46935aa8cc9a4d6a77a20af4496c362 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 27 May 2019 07:20:31 +0200 Subject: [PATCH 3/6] Review --- workflow.rst | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/workflow.rst b/workflow.rst index b668e6f5fa0..69eb91984ac 100644 --- a/workflow.rst +++ b/workflow.rst @@ -90,35 +90,28 @@ like this: - currentPlace - App\Entity\BlogPost - + draft draft reviewed rejected published - draft reviewed - reviewed published - reviewed rejected - - @@ -138,6 +131,7 @@ like this: 'property' => ['currentPlace'] ], 'supports' => ['App\Entity\BlogPost'], + 'initial_marking' => 'draft', 'places' => [ 'draft', 'reviewed', @@ -618,8 +612,8 @@ requires: reviewed published - 20 - You can not publish after 8 PM. + 20 + You can not publish after 8 PM. From 7bb204129d091f0fbfbadc0c7b2821c9e55165c1 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 27 May 2019 07:26:04 +0200 Subject: [PATCH 4/6] Fix indent --- workflow/introduction.rst | 76 +++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/workflow/introduction.rst b/workflow/introduction.rst index 0b146164f03..385ec8e8cd1 100644 --- a/workflow/introduction.rst +++ b/workflow/introduction.rst @@ -190,46 +190,46 @@ Below is the configuration for the pull request state machine. // ... 'workflows' => [ 'pull_request' => [ - 'type' => 'state_machine', - 'supports' => ['App\Entity\PullRequest'], - 'places' => [ - 'start', - 'coding', - 'test', - 'review', - 'merged', - 'closed', - ], - 'transitions' => [ - 'submit'=> [ - 'from' => 'start', - 'to' => 'test', + 'type' => 'state_machine', + 'supports' => ['App\Entity\PullRequest'], + 'places' => [ + 'start', + 'coding', + 'test', + 'review', + 'merged', + 'closed', ], - 'update'=> [ - 'from' => ['coding', 'test', 'review'], - 'to' => 'test', + 'transitions' => [ + 'submit'=> [ + 'from' => 'start', + 'to' => 'test', + ], + 'update'=> [ + 'from' => ['coding', 'test', 'review'], + 'to' => 'test', + ], + 'wait_for_review'=> [ + 'from' => 'test', + 'to' => 'review', + ], + 'request_change'=> [ + 'from' => 'review', + 'to' => 'coding', + ], + 'accept'=> [ + 'from' => 'review', + 'to' => 'merged', + ], + 'reject'=> [ + 'from' => 'review', + 'to' => 'closed', + ], + 'reopen'=> [ + 'from' => 'start', + 'to' => 'review', + ], ], - 'wait_for_review'=> [ - 'from' => 'test', - 'to' => 'review', - ], - 'request_change'=> [ - 'from' => 'review', - 'to' => 'coding', - ], - 'accept'=> [ - 'from' => 'review', - 'to' => 'merged', - ], - 'reject'=> [ - 'from' => 'review', - 'to' => 'closed', - ], - 'reopen'=> [ - 'from' => 'start', - 'to' => 'review', - ], - ], ], ], ]); From a640d147c5981f482ae7fbeb4254ac5c27c79275 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 16 May 2019 19:10:03 +0200 Subject: [PATCH 5/6] [Workflow] config doc --- components/workflow.rst | 3 +- workflow.rst | 3 +- workflow/dumping-workflows.rst | 106 ++++++++++++++++----------------- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/components/workflow.rst b/components/workflow.rst index 137695ddb0f..de936fa5baa 100644 --- a/components/workflow.rst +++ b/components/workflow.rst @@ -79,10 +79,11 @@ Usage ----- When you have configured a ``Registry`` with your workflows, -you can retrieve a workflow from it and use it as follows:: +you can retreive a workflow from it and use it as follows:: // ... // Consider that $blogPost is in place "draft" by default + // Consider that $post is in state "draft" by default $blogPost = new BlogPost(); $workflow = $registry->get($blogPost); diff --git a/workflow.rst b/workflow.rst index 69eb91984ac..a0573f3c9e9 100644 --- a/workflow.rst +++ b/workflow.rst @@ -182,7 +182,7 @@ what actions are allowed on a blog post:: use App\Entity\BlogPost; use Symfony\Component\Workflow\Exception\LogicException; - $post = BlogPost(); + $post = new BlogPost(); $workflow = $this->container->get('workflow.blog_publishing'); $workflow->can($post, 'publish'); // False @@ -664,6 +664,7 @@ Then you can access this metadata in your controller as follows:: use App\Entity\BlogPost; use Symfony\Component\Workflow\Registry; + use App\Entity\BlogPost; public function myController(Registry $registry, BlogPost $post) { diff --git a/workflow/dumping-workflows.rst b/workflow/dumping-workflows.rst index 78a2d566606..2499dd35225 100644 --- a/workflow/dumping-workflows.rst +++ b/workflow/dumping-workflows.rst @@ -228,63 +228,63 @@ Below is the configuration for the pull request state machine with styling added // ... 'workflows' => [ 'pull_request' => [ - 'type' => 'state_machine', - 'supports' => ['App\Entity\PullRequest'], - 'places' => [ - 'start', - 'coding', - 'test', - 'review' => [ - 'metadata' => [ - 'description' => 'Human review', + 'type' => 'state_machine', + 'supports' => ['App\Entity\PullRequest'], + 'places' => [ + 'start', + 'coding', + 'test', + 'review' => [ + 'metadata' => [ + 'description' => 'Human review', + ], ], - ], - 'merged', - 'closed' => [ - 'metadata' => [ - 'bg_color' => 'DeepSkyBlue', + 'merged', + 'closed' => [ + 'metadata' => [ + 'bg_color' => 'DeepSkyBlue', + ], ], ], - ], - 'transitions' => [ - 'submit'=> [ - 'from' => 'start', - 'to' => 'test', - ], - 'update'=> [ - 'from' => ['coding', 'test', 'review'], - 'to' => 'test', - 'metadata' => [ - 'arrow_color' => 'Turquoise', - ], - ], - 'wait_for_review'=> [ - 'from' => 'test', - 'to' => 'review', - 'metadata' => [ - 'color' => 'Orange', - ], - ], - 'request_change'=> [ - 'from' => 'review', - 'to' => 'coding', - ], - 'accept'=> [ - 'from' => 'review', - 'to' => 'merged', - 'metadata' => [ - 'label' => 'Accept PR', - ], - ], - 'reject'=> [ - 'from' => 'review', - 'to' => 'closed', - ], - 'reopen'=> [ - 'from' => 'start', - 'to' => 'review', + 'transitions' => [ + 'submit'=> [ + 'from' => 'start', + 'to' => 'test', + ], + 'update'=> [ + 'from' => ['coding', 'test', 'review'], + 'to' => 'test', + 'metadata' => [ + 'arrow_color' => 'Turquoise', + ], + ], + 'wait_for_review'=> [ + 'from' => 'test', + 'to' => 'review', + 'metadata' => [ + 'color' => 'Orange', + ], + ], + 'request_change'=> [ + 'from' => 'review', + 'to' => 'coding', + ], + 'accept'=> [ + 'from' => 'review', + 'to' => 'merged', + 'metadata' => [ + 'label' => 'Accept PR', + ], + ], + 'reject'=> [ + 'from' => 'review', + 'to' => 'closed', + ], + 'reopen'=> [ + 'from' => 'start', + 'to' => 'review', + ], ], - ], ], ], ]); From fdc221b525399c9dd1c970d622dac2127cb538c4 Mon Sep 17 00:00:00 2001 From: Wouter J Date: Mon, 12 Aug 2019 22:42:59 +0200 Subject: [PATCH 6/6] Minor XML improvement --- workflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow.rst b/workflow.rst index a0573f3c9e9..f477ace9665 100644 --- a/workflow.rst +++ b/workflow.rst @@ -94,7 +94,7 @@ like this: currentPlace App\Entity\BlogPost - draft + draft draft reviewed rejected