소스 검색

Added possibility to automatically set container on workers implementing ContainerAwareInterface

Thorsten Rinne 13 년 전
부모
커밋
929fa68250
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) {