فهرست منبع

Update command workflow:apply

Espinoza Guillermo 6 سال پیش
والد
کامیت
bf48f7a3d8
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      Command/WorkflowApplyCommand.php

+ 7 - 1
Command/WorkflowApplyCommand.php

@@ -79,12 +79,18 @@ class WorkflowApplyCommand extends ContainerAwareCommand
             throw new \Exception("Entity $entityClass with id $entityId not found");
         }
         
+        // Si no se pasa workflow como parametro se busca según el workflow que tenga
+        // asignado la $entity
         if (is_null($workflow)) {
             $workflow = "{$entity->getWorkflowType()}.{$entity->getWorkflowName()}";
         }
         
         $wreg = $this->getContainer()->get("workflow.registry");
-        $wf = $wreg->get($entity, $workflow);
+        try {
+            $wf = $wreg->get($entity, $workflow);
+        } catch (\Exception $ex) {
+            $wf = $this->getContainer()->get($workflow);
+        }
         $transitions = array_map(function($obj) {
             return $obj->getName();
         }, $wf->getEnabledTransitions($entity));