@@ -24,17 +24,17 @@ class WorkflowRegistry
24
24
/**
25
25
* @var Registry
26
26
*/
27
- private $ registry ;
27
+ protected $ registry ;
28
28
29
29
/**
30
30
* @var array
31
31
*/
32
- private $ config ;
32
+ protected $ config ;
33
33
34
34
/**
35
35
* @var EventDispatcher
36
36
*/
37
- private $ dispatcher ;
37
+ protected $ dispatcher ;
38
38
39
39
/**
40
40
* WorkflowRegistry constructor
@@ -44,11 +44,11 @@ class WorkflowRegistry
44
44
*/
45
45
public function __construct (array $ config )
46
46
{
47
- $ this ->registry = new Registry ();
48
- $ this ->config = $ config ;
47
+ $ this ->registry = new Registry ();
48
+ $ this ->config = $ config ;
49
49
$ this ->dispatcher = new EventDispatcher ();
50
50
51
- $ subscriber = new WorkflowSubscriber ();
51
+ $ subscriber = new WorkflowSubscriber ();
52
52
$ this ->dispatcher ->addSubscriber ($ subscriber );
53
53
54
54
foreach ($ this ->config as $ name => $ workflowData ) {
@@ -71,10 +71,10 @@ public function get($subject, $workflowName = null)
71
71
/**
72
72
* Add a workflow to the subject
73
73
*
74
- * @param Workflow $workflow
75
- * @param SupportStrategyInterface $supportStrategy
74
+ * @param Workflow $workflow
75
+ * @param string $supportStrategy
76
76
*/
77
- public function add (Workflow $ workflow , SupportStrategyInterface $ supportStrategy )
77
+ public function add (Workflow $ workflow , $ supportStrategy )
78
78
{
79
79
$ this ->registry ->add ($ workflow , new ClassInstanceSupportStrategy ($ supportStrategy ));
80
80
}
@@ -98,9 +98,9 @@ public function addFromArray($name, array $workflowData)
98
98
$ builder ->addTransition (new Transition ($ transitionName , $ transition ['from ' ], $ transition ['to ' ]));
99
99
}
100
100
101
- $ definition = $ builder ->build ();
101
+ $ definition = $ builder ->build ();
102
102
$ markingStore = $ this ->getMarkingStoreInstance ($ workflowData );
103
- $ workflow = $ this ->getWorkflowInstance ($ name , $ workflowData , $ definition , $ markingStore );
103
+ $ workflow = $ this ->getWorkflowInstance ($ name , $ workflowData , $ definition , $ markingStore );
104
104
105
105
foreach ($ workflowData ['supports ' ] as $ supportedClass ) {
106
106
$ this ->add ($ workflow , $ supportedClass );
@@ -116,19 +116,18 @@ public function addFromArray($name, array $workflowData)
116
116
* @param MarkingStoreInterface $markingStore
117
117
* @return Workflow
118
118
*/
119
- private function getWorkflowInstance (
119
+ protected function getWorkflowInstance (
120
120
$ name ,
121
121
array $ workflowData ,
122
122
Definition $ definition ,
123
123
MarkingStoreInterface $ markingStore
124
124
) {
125
- $ type = isset ($ workflowData ['type ' ]) ? $ workflowData ['type ' ] : 'workflow ' ;
126
- $ className = Workflow::class;
127
-
128
- if ($ type === 'state_machine ' ) {
129
- $ className = StateMachine::class;
130
- } elseif (isset ($ workflowData ['class ' ])) {
125
+ if (isset ($ workflowData ['class ' ])) {
131
126
$ className = $ workflowData ['class ' ];
127
+ } elseif (isset ($ workflowData ['type ' ]) && $ workflowData ['type ' ] === 'state_machine ' ) {
128
+ $ className = StateMachine::class;
129
+ } else {
130
+ $ className = Workflow::class;
132
131
}
133
132
134
133
return new $ className ($ definition , $ markingStore , $ this ->dispatcher , $ name );
@@ -141,17 +140,17 @@ private function getWorkflowInstance(
141
140
* @return MarkingStoreInterface
142
141
* @throws \ReflectionException
143
142
*/
144
- private function getMarkingStoreInstance (array $ workflowData )
143
+ protected function getMarkingStoreInstance (array $ workflowData )
145
144
{
146
145
$ markingStoreData = isset ($ workflowData ['marking_store ' ]) ? $ workflowData ['marking_store ' ] : [];
147
- $ type = isset ($ markingStoreData ['type ' ]) ? $ markingStoreData ['type ' ] : 'single_state ' ;
148
- $ className = SingleStateMarkingStore::class;
149
- $ arguments = isset ($ markingStoreData ['arguments ' ]) ? $ markingStoreData ['arguments ' ] : [];
146
+ $ arguments = isset ($ markingStoreData ['arguments ' ]) ? $ markingStoreData ['arguments ' ] : [];
150
147
151
- if ($ type === 'multiple_state ' ) {
152
- $ className = MultipleStateMarkingStore::class;
153
- } elseif (isset ($ markingStoreData ['class ' ])) {
148
+ if (isset ($ markingStoreData ['class ' ])) {
154
149
$ className = $ markingStoreData ['class ' ];
150
+ } elseif (isset ($ markingStoreData ['type ' ]) && $ markingStoreData ['type ' ] === 'multiple_state ' ) {
151
+ $ className = MultipleStateMarkingStore::class;
152
+ } else {
153
+ $ className = SingleStateMarkingStore::class;
155
154
}
156
155
157
156
$ class = new \ReflectionClass ($ className );
0 commit comments