Jelajahi Sumber

[GearmanBundle] Some fixes to make it work

mmoreramerino 13 tahun lalu
induk
melakukan
f33d89e8d4

+ 2 - 0
lib/Mmoreramerino/GearmanBundle/Command/GearmanCheckCommand.php

@@ -55,5 +55,7 @@ class GearmanCheckCommand extends ContainerAwareCommand
         }
 
         $output->writeln('<comment>Gearman is succesfuly installed</comment>');
+
+        $this->getContainer()->get('gearman')->doNormalJob('MmoreramerinoGearmanBundleWorkerstestWorker~testB');
     }
 }

MmoreramerinoGearmanBundle.php → lib/Mmoreramerino/GearmanBundle/MmoreramerinoGearmanBundle.php


+ 12 - 9
lib/Mmoreramerino/GearmanBundle/Service/GearmanCacheLoader.php

@@ -115,18 +115,21 @@ class GearmanCacheLoader extends ContainerAware
         if (null === $this->bundles) {
             $this->bundles = array();
 
-            foreach ($this->settings['bundles'] as $properties) {
+            if (isset($this->settings['bundles']) && is_array($this->settings['bundles']) && !empty($this->settings['bundles'])) {
 
-                if ( isset($properties['active']) && (true === $properties['active']) ) {
+                foreach ($this->settings['bundles'] as $properties) {
 
-                    if ('' !== $properties['namespace']) {
-                        $this->bundles[] = $properties['namespace'];
-                    }
+                    if ( isset($properties['active']) && (true === $properties['active']) ) {
+
+                        if ('' !== $properties['namespace']) {
+                            $this->bundles[] = $properties['namespace'];
+                        }
 
-                    if (isset($properties['ignore'])) {
-                        $ignored = (array) $properties['ignore'];
-                        while ($ignored) {
-                            $this->ignored[] = $properties['namespace'] . '\\' . array_shift($ignored);
+                        if (isset($properties['ignore'])) {
+                            $ignored = (array) $properties['ignore'];
+                            while ($ignored) {
+                                $this->ignored[] = $properties['namespace'] . '\\' . array_shift($ignored);
+                            }
                         }
                     }
                 }

+ 2 - 0
lib/Mmoreramerino/GearmanBundle/Workers/testWorker.php

@@ -2,6 +2,8 @@
 
 namespace Mmoreramerino\GearmanBundle\Workers;
 
+use Mmoreramerino\GearmanBundle\Driver\Gearman;
+
 /** @Gearman\Work(description="Worker test description", defaultMethod="doBackground") */
 class testWorker
 {