Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commita33a90a

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: [Workflow] Mention the `workflow.marking_store.service` option
2 parentseedca34 +0ccde46 commita33a90a

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

‎workflow.rst‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,83 @@ place::
909909
}
910910
}
911911

912+
Creating Your Own Marking Store
913+
-------------------------------
914+
915+
You may need to implement your own store to execute some additional logic
916+
when the marking is updated. For example, you may have some specific needs
917+
to store the marking on certain workflows. To do this, you need to implement
918+
the
919+
:class:`Symfony\\Component\\Workflow\\MarkingStore\\MarkingStoreInterface`::
920+
921+
namespace App\Workflow\MarkingStore;
922+
923+
use Symfony\Component\Workflow\Marking;
924+
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
925+
926+
final class BlogPostMarkingStore implements MarkingStoreInterface
927+
{
928+
public function getMarking(BlogPost $subject): Marking
929+
{
930+
return new Marking([$subject->getCurrentPlace() => 1]);
931+
}
932+
933+
public function setMarking(BlogPost $subject, Marking $marking): void
934+
{
935+
$marking = key($marking->getPlaces());
936+
$subject->setCurrentPlace($marking);
937+
}
938+
}
939+
940+
Once your marking store is implemented, you can configure your workflow to use
941+
it:
942+
943+
..configuration-block::
944+
945+
..code-block::yaml
946+
947+
# config/packages/workflow.yaml
948+
framework:
949+
workflows:
950+
blog_publishing:
951+
# ...
952+
marking_store:
953+
service:'App\Workflow\MarkingStore\BlogPostMarkingStore'
954+
955+
..code-block::xml
956+
957+
<!-- config/packages/workflow.xml-->
958+
<?xml version="1.0" encoding="UTF-8" ?>
959+
<containerxmlns="http://symfony.com/schema/dic/services"
960+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
961+
xmlns:framework="http://symfony.com/schema/dic/symfony"
962+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
963+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
964+
>
965+
<framework:config>
966+
<framework:workflowname="blog_publishing">
967+
<!-- ...-->
968+
<framework:marking-storeservice="App\Workflow\MarkingStore\BlogPostMarkingStore"/>
969+
</framework:workflow>
970+
</framework:config>
971+
</container>
972+
973+
..code-block::php
974+
975+
// config/packages/workflow.php
976+
use App\Workflow\MarkingStore\ReflectionMarkingStore;
977+
use Symfony\Config\FrameworkConfig;
978+
979+
return static function (FrameworkConfig $framework): void {
980+
// ...
981+
982+
$blogPublishing = $framework->workflows()->workflows('blog_publishing');
983+
// ...
984+
985+
$blogPublishing->markingStore()
986+
->service(BlogPostMarkingStore::class);
987+
};
988+
912989
Usage in Twig
913990
-------------
914991

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp