Explorar o código

Added possibility to automatically set container on workers implementing ContainerAwareInterface

Thorsten Rinne %!s(int64=13) %!d(string=hai) anos
pai
achega
929fa68250
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      lib/Mmoreramerino/GearmanBundle/Service/GearmanExecute.php

+ 3 - 3
lib/Mmoreramerino/GearmanBundle/Service/GearmanExecute.php

@@ -47,13 +47,13 @@ class GearmanExecute extends GearmanService
             $this->addServers($gmworker, $worker['servers']);
         }
 
-
-
-
         if (null !== $worker['service']) {
             $objInstance = $this->container->get($worker['service']);
         } else {
             $objInstance = new $worker['className'];
+            if ($objInstance instanceof \Symfony\Component\DependencyInjection\ContainerAwareInterface) {
+                $objInstance->setContainer($this->container);
+            }
         }
 
         foreach ($jobs as $job) {