File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 10
10
<tag name =" kernel.event_subscriber" />
11
11
</service >
12
12
13
+ <service id =" workflow.auto_transition" class =" AppBundle\Workflow\AutoTransitionListener" >
14
+ <argument type =" service" id =" workflow.article" />
15
+ <tag name =" kernel.event_subscriber" />
16
+ </service >
17
+
13
18
<service id =" workflow.twig_extension_developer" class =" AppBundle\Twig\WorkflowExtension" >
14
19
<argument type =" service" id =" workflow.registry" />
15
20
<tag name =" twig.extension" />
Original file line number Diff line number Diff line change
1
+ <?php
DF0B
2
+
3
+ namespace AppBundle \Workflow ;
4
+
5
+ use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
6
+ use Symfony \Component \Security \Core \Authorization \AuthorizationCheckerInterface ;
7
+ use Symfony \Component \Workflow \Event \Event ;
8
+ use Symfony \Component \Workflow \Event \GuardEvent ;
9
+ use Symfony \Component \Workflow \Workflow ;
10
+
11
+ class AutoTransitionListener implements EventSubscriberInterface
12
+ {
13
+ private $ workflow ;
14
+
15
+ public function __construct (Workflow $ workflow )
16
+ {
17
+ $ this ->workflow = $ workflow ;
18
+ }
19
+
20
+ public function onAnnouncePublish (Event $ event )
21
+ {
22
+ $ this ->workflow ->apply ($ event ->getSubject (), 'publish ' );
23
+ }
24
+
25
+ public static function getSubscribedEvents ()
26
+ {
27
+ return array (
28
+ 'workflow.article.announce.publish ' => 'onAnnouncePublish ' ,
29
+ );
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments