2
2
3
3
namespace Safemood \Workflow \Traits ;
4
4
5
- use Illuminate \Contracts \Queue \ShouldQueue ;
5
+ use Illuminate \Foundation \Bus \Dispatchable as DispatchableJob ;
6
+ use Illuminate \Foundation \Events \Dispatchable as DispatchableEvent ;
6
7
use Safemood \Workflow \Enums \ActionState ;
7
8
8
9
trait ManagesExecution
@@ -75,8 +76,8 @@ protected function executeActions(array $actions, array &$context)
75
76
$ this ->initializeActionState ($ action );
76
77
77
78
try {
78
- if ($ this ->isJobAction ($ action )) {
79
- $ this ->dispatchJob ($ action , $ context );
79
+ if ($ this ->isDispatchable ($ action )) {
80
+ $ this ->dispatchAction ($ action , $ context );
80
81
} else {
81
82
$ this ->handleAction ($ action , $ context );
82
83
}
@@ -99,13 +100,18 @@ protected function handleAction($action, array &$context)
99
100
$ action ->handle ($ context );
100
101
}
101
102
102
- protected function isJobAction ($ action ): bool
103
+ protected function isDispatchable ($ action ): bool
103
104
{
105
+ $ traits = class_uses ($ action );
106
+
107
+ return ! empty (array_intersect ($ traits , [
108
+ DispatchableJob::class,
109
+ DispatchableEvent::class,
110
+ ]));
104
111
105
- return $ action instanceof ShouldQueue;
106
112
}
107
113
108
- protected function dispatchJob ($ action , array &$ context ): void
114
+ protected function dispatchAction ($ action , array &$ context ): void
109
115
{
110
116
111
117
$ action ::dispatch ($ context );
0 commit comments