@@ -164,14 +164,7 @@ public function getWorkflowInstances(?Workflow $workflow, string $status = null)
164164 $ paramsStatus = empty ($ status ) ? GetWorkflowInstancesDetailCommand::FILTERS : [$ status ];
165165 $ instances = new ArrayCollection ([]);
166166 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 );
175168 }
176169 if (!is_null ($ status )) {
177170 return $ instances ->get (strtolower ($ status ))->get ('workflow_instances ' );
@@ -180,6 +173,26 @@ public function getWorkflowInstances(?Workflow $workflow, string $status = null)
180173 return $ instances ;
181174 }
182175
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+
183196 /**
184197 * {@inheritdoc}
185198 */
0 commit comments