소스 검색

Minor fix, ONU entity has two possible workflow to use

Guillermo Espinoza 6 년 전
부모
커밋
eaa73fe33d
1개의 변경된 파일15개의 추가작업 그리고 11개의 파일을 삭제
  1. 15 11
      src/FTTHBundle/Controller/REST/ONURESTController.php

+ 15 - 11
src/FTTHBundle/Controller/REST/ONURESTController.php

@@ -95,7 +95,7 @@ class ONURESTController extends RESTController
         $tenancyService = $this->getTenancyService();
 
         try {
-            
+
         $em = $this->container->get("doctrine.orm.entity_manager");
         $tenancyService->disableFilter();
         $entity = $em->getRepository('FTTHBundle:ONU')->find($id);
@@ -143,26 +143,30 @@ class ONURESTController extends RESTController
             $query = $em->createQuery('SELECT o FROM FTTHBundle:ONU o WHERE o.currentState != :transition AND o.clientId = :client')->setParameter('transition', $transition)->setParameter('client', $id);
             $onus = $query->getResult();
             $tenancyService->enableFilter();
-            
+
             $cmd_args = array();
             $cmd_args['entity'] = '--entity:FTTHBundle\\Entity\\ONU';
-            $cmd_args['workflow'] = '--workflow:onu_workflow';
             $cmd_args['transition'] = "--transition:{$transition}";
-            
-            $serialNumbers = array();
-            if($onus) {
 
-                foreach($onus as $onu) {
+            $serialNumbers = array();
+            if ($onus) {
+                foreach ($onus as $onu) {
                     $onuId = $onu->getId();
                     $cmd_args['id'] = "--id:{$onuId}";
+                    $workflowName = $onu->getWorkflow()->getName();
+                    $cmd_args['workflow'] = "--workflow:{$workflowName}";
                     $serialNumbers[$onuId] = $onu->getPonSerialNumber();
-                    
+
                     $this->runCommand('workflow:apply', $cmd_args);
                 }
             }
 
-            return array('client' => $id, 'transition' => $transition, "count" => count($onus), 'onus' => $serialNumbers);
-
+            return array(
+                'client' => $id,
+                'transition' => $transition,
+                'count' => count($onus),
+                'onus' => $serialNumbers
+            );
         } catch (\Exception $e) {
             return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
         }
@@ -173,7 +177,7 @@ class ONURESTController extends RESTController
      * @global kernel $kernel
      *
      * @param string $name
-     * @param array $args
+     * @param array $cmd_args
      *
      * @return string
      */