@@ -164,14 +164,7 @@ public function getWorkflowInstances(?Workflow $workflow, string $status = null)
164
164
$ paramsStatus = empty ($ status ) ? GetWorkflowInstancesDetailCommand::FILTERS : [$ status ];
165
165
$ instances = new ArrayCollection ([]);
166
166
foreach ($ paramsStatus as $ stat ) {
167
- $ instances [strtolower ($ stat )] = $ this ->_dispatch (new Command \GetWorkflowInstancesCommand ($ workflow , $ stat ));
168
- /** @var ArrayCollection $workflowCollection */
169
- $ workflowCollection = $ instances [strtolower ($ stat )]->get ('workflow_instances ' );
170
- if (!empty ($ workflowCollection )) {
171
- foreach ($ workflowCollection as $ instance ) {
172
- $ this ->getCurrentClass ()->getWorkflowInstancesDetails ($ instance );
173
- }
174
- }
167
+ $ instances [strtolower ($ stat )] = $ this ->getStatusInstance ($ stat , $ workflow );
175
168
}
176
169
if (!is_null ($ status )) {
177
170
return $ instances ->get (strtolower ($ status ))->get ('workflow_instances ' );
@@ -180,6 +173,26 @@ public function getWorkflowInstances(?Workflow $workflow, string $status = null)
180
173
return $ instances ;
181
174
}
182
175
176
+ /**
177
+ * @param $stat
178
+ * @param Workflow|null $workflow
179
+ *
180
+ * @return ArrayCollection
181
+ * @throws Exception\ClientException
182
+ */
183
+ protected function getStatusInstance ($ stat , ?Workflow $ workflow )
184
+ {
185
+ $ workflowInstances = $ this ->_dispatch (new Command \GetWorkflowInstancesCommand ($ workflow , $ stat ));
186
+ /** @var ArrayCollection $workflowCollection */
187
+ $ workflowCollection = $ workflowInstances ->get ('workflow_instances ' );
188
+ if (!empty ($ workflowCollection )) {
189
+ foreach ($ workflowCollection as $ instance ) {
190
+ $ this ->getCurrentClass ()->getWorkflowInstancesDetails ($ instance );
191
+ }
192
+ }
193
+ return $ workflowInstances ;
194
+ }
195
+
183
196
/**
184
197
* {@inheritdoc}
185
198
*/
0 commit comments