Browse Source

Se añade truco para ejecutar el atributo 'name' como comando, debe enviarse --args=--executeName. No se utiliza bin/console.

Maxi Schvindt 7 years ago
parent
commit
d868429d37
1 changed files with 10 additions and 4 deletions
  1. 10 4
      Services/CommandConsumer.php

+ 10 - 4
Services/CommandConsumer.php

@@ -34,6 +34,7 @@ class CommandConsumer implements ConsumerInterface
     public function execute(AMQPMessage $msg)
     {
         $msgBody = unserialize($msg->body);
+
         if (isset($msgBody['name']) && isset($msgBody['args'])) {
             // command name and args
             $name = $msgBody['name'];
@@ -52,12 +53,17 @@ class CommandConsumer implements ConsumerInterface
                     $input[] = preg_replace('/:/', '=', $arg, 1);
                 }
             }
-            
-            $consolePath = $this->serviceContainer->get('kernel')->getRootDir() . '/../bin/console';
-            $command = $name . ' ' . implode(' ', $input);
+
+            if(in_array("--executeName",$input)) {
+                $execute = $name;
+            } else {
+                $consolePath = $this->serviceContainer->get('kernel')->getRootDir() . '/../bin/console';
+                $command = $name . ' ' . implode(' ', $input);
+                $execute = "{$consolePath} {$command}";
+            }
             
             try {
-                $process = new Process("{$consolePath} {$command}");
+                $process = new Process($execute);
                 $process->setTimeout(10 * 60);
                 $process->run();