浏览代码

Merge pull request #12 from thorsten/development

Added possibility to automatically set container on workers implementing...
Marc 13 年之前
父节点
当前提交
eb9ce31157
共有 1 个文件被更改,包括 3 次插入3 次删除
  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) {