فهرست منبع

el routing key se obtiene del entorno o si se paso por parametro

Luciano Andrade 7 سال پیش
والد
کامیت
2adbaaabc4
1فایلهای تغییر یافته به همراه9 افزوده شده و 10 حذف شده
  1. 9 10
      Services/ProducerService.php

+ 9 - 10
Services/ProducerService.php

@@ -53,11 +53,7 @@ class ProducerService
             $actionRepository = $this->getEntityManager()->getRepository('WorkflowBundle:Action');
             $actions = $actionRepository->findAllByEventAndObjectClass($eventName, $entityClass);
             foreach ($actions as $action) {
-                $routing_key = "";
-                if(getenv("AMQP_KEY") !== false){
-                        $routing_key = getenv("AMQP_KEY");
-                }
-                $this->publishMessage($action, $entity, $routing_key);
+                $this->publishMessage($action, $entity);
             }
         }
     }
@@ -78,10 +74,7 @@ class ProducerService
         $entityRepository = $entityManager->getRepository($entityClass);
         $entity = $entityRepository->find($entityId);
         if (in_array($entityClass, WorkFlowEntityClasses::getConstants())) {
-	    $routing_key = "";
-            if(getenv("AMQP_KEY") !== false){
-                $routing_key = getenv("AMQP_KEY");
-            }
+	    
             $this->publishMessage($action, $entity);
         }
     }
@@ -90,8 +83,14 @@ class ProducerService
      * @param Action $action
      * @param Entity $entity
      */
-    public function publishMessage(Action $action, $entity, $routing_key = "")
+    public function publishMessage(Action $action, $entity, $routing_key = false)
     {
+        if($routing_key === false){
+		$routing_key = "";
+		if(getenv("AMQP_KEY") !== false){
+		     $routing_key = getenv("AMQP_KEY");
+		}
+        }
         $entityClass = get_class($entity);
         $actionName = $action->getName();
         $entityId = $entity->getId();