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 175807f

Browse filesBrowse files
[Workflow] Mention the workflow.marking_store.service option
1 parent 6fb8828 commit 175807f
Copy full SHA for 175807f

File tree

Expand file treeCollapse file tree

1 file changed

+77
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+77
-0
lines changed

‎workflow.rst

Copy file name to clipboardExpand all lines: workflow.rst
+77Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,83 @@ place::
813813
}
814814
}
815815

816+
Creating Your Own Marking Store
817+
-------------------------------
818+
819+
You may need to implement your own store to execute some additional logic
820+
when the marking is updated. For example, you may have some specific needs
821+
to store the marking on certain workflows. To do this, you need to implement
822+
the
823+
:class:`Symfony\\Component\\Workflow\\MarkingStore\\MarkingStoreInterface`::
824+
825+
namespace App\Workflow\MarkingStore;
826+
827+
use Symfony\Component\Workflow\Marking;
828+
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
829+
830+
final class BlogPostMarkingStore implements MarkingStoreInterface
831+
{
832+
public function getMarking(BlogPost $subject): Marking
833+
{
834+
return new Marking([$subject->getCurrentPlace() => 1]);
835+
}
836+
837+
public function setMarking(BlogPost $subject, Marking $marking): void
838+
{
839+
$marking = key($marking->getPlaces());
840+
$subject->setCurrentPlace($marking);
841+
}
842+
}
843+
844+
Once your marking store is implemented, you can configure your workflow to use
845+
it:
846+
847+
.. configuration-block::
848+
849+
.. code-block:: yaml
850+
851+
# config/packages/workflow.yaml
852+
framework:
853+
workflows:
854+
blog_publishing:
855+
# ...
856+
marking_store:
857+
service: 'App\Workflow\MarkingStore\BlogPostMarkingStore'
858+
859+
.. code-block:: xml
860+
861+
<!-- config/packages/workflow.xml -->
862+
<?xml version="1.0" encoding="UTF-8" ?>
863+
<container xmlns="http://symfony.com/schema/dic/services"
864+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
865+
xmlns:framework="http://symfony.com/schema/dic/symfony"
866+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
867+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
868+
>
869+
<framework:config>
870+
<framework:workflow name="blog_publishing">
871+
<!-- ... -->
872+
<framework:marking-store service="App\Workflow\MarkingStore\BlogPostMarkingStore"/>
873+
</framework:workflow>
874+
</framework:config>
875+
</container>
876+
877+
.. code-block:: php
878+
879+
// config/packages/workflow.php
880+
use App\Workflow\MarkingStore\ReflectionMarkingStore;
881+
use Symfony\Config\FrameworkConfig;
882+
883+
return static function (FrameworkConfig $framework): void {
884+
// ...
885+
886+
$blogPublishing = $framework->workflows()->workflows('blog_publishing');
887+
// ...
888+
889+
$blogPublishing->markingStore()
890+
->service(BlogPostMarkingStore::class);
891+
};
892+
816893
Usage in Twig
817894
-------------
818895

0 commit comments

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