ソースを参照

Merge pull request #7 from Spea/development

Forwards compatibility for Doctrine2.2, update for composer.json
Marc 13 年 前
コミット
587da6031d
3 ファイル変更34 行追加12 行削除
  1. 8 8
      Module/WorkerClass.php
  2. 14 4
      Service/GearmanCacheLoader.php
  3. 12 0
      composer.json

+ 8 - 8
Module/WorkerClass.php

@@ -2,7 +2,7 @@
 
 namespace Mmoreramerino\GearmanBundle\Module;
 
-use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\Common\Annotations\Reader;
 use Mmoreramerino\GearmanBundle\Driver\Gearman\Work;
 use Mmoreramerino\GearmanBundle\Module\JobCollection;
 use Mmoreramerino\GearmanBundle\Module\JobClass as Job;
@@ -44,20 +44,20 @@ class WorkerClass
      *
      * @param Work             $classAnnotation ClassAnnotation class
      * @param \ReflectionClass $reflectionClass Reflexion class
-     * @param AnnotationReader $reader          ReaderAnnotation class
+     * @param Reader           $reader          ReaderAnnotation class
      * @param array            $settings        Settings array
      */
-    public function __construct( Work $classAnnotation, \ReflectionClass $reflectionClass, AnnotationReader $reader, array $settings)
+    public function __construct(Work $classAnnotation, \ReflectionClass $reflectionClass, Reader $reader, array $settings)
     {
         $this->namespace = $reflectionClass->getNamespaceName();
 
         $this->callableName =   str_replace('\\', '', ((null !== $classAnnotation->name) ?
-                                ($this->namespace .'\\' .$classAnnotation->name) :
-                                $reflectionClass->getName()));
+            ($this->namespace .'\\' .$classAnnotation->name) :
+            $reflectionClass->getName()));
 
         $this->description =    (null !== $classAnnotation->description) ?
-                                $classAnnotation->description :
-                                'No description is defined';
+            $classAnnotation->description :
+            'No description is defined';
 
         $this->fileName = $reflectionClass->getFileName();
         $this->className = $reflectionClass->getName();
@@ -143,4 +143,4 @@ class WorkerClass
         return $dump;
     }
 
-}
+}

+ 14 - 4
Service/GearmanCacheLoader.php

@@ -53,12 +53,22 @@ class GearmanCacheLoader extends ContainerAware
      */
     public function load(GearmanCache $cache)
     {
-        $reader = new AnnotationReader();
-        AnnotationRegistry::registerFile(__DIR__ . "/../Driver/Gearman/GearmanAnnotations.php");
-        $reader->setDefaultAnnotationNamespace('Mmoreramerino\GearmanBundle\Driver\\');
+        if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
+            // Register the ORM Annotations in the AnnotationRegistry
+            AnnotationRegistry::registerFile(__DIR__ . "/../Driver/Gearman/GearmanAnnotations.php");
+
+            $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
+            $reader->addNamespace('Mmoreramerino\GearmanBundle\Driver');
+        } else {
+            // Register the ORM Annotations in the AnnotationRegistry
+            AnnotationRegistry::registerFile(__DIR__ . "/../Driver/Gearman/GearmanAnnotations.php");
+
+            $reader = new AnnotationReader();
+            $reader->setDefaultAnnotationNamespace('Mmoreramerino\GearmanBundle\Driver\\');
+        }
+
         $workerCollection = new WorkerCollection;
         $bundles = $this->container->get('kernel')->getBundles();
-
         foreach ($bundles as $bundle) {
             if (!\in_array($bundle->getNamespace(), $this->getParseableBundles())) {
                 continue;

+ 12 - 0
composer.json

@@ -2,13 +2,25 @@
     "name": "Mmoreramerino/gearman-bundle",
     "description": "Adds gearman support",
     "keywords": ["gearman"],
+    "homepage": "http://mmoreramerino.github.com/GearmanBundle/",
     "type": "symfony-bundle",
     "license": "Apache",
     "authors": [
         {
             "name": "Marc Morera",
             "email": "marc@ulabox.com"
+        },
+        {
+            "name": "Symfony Community",
+            "homepage": "https://github.com/mmoreramerino/GearmanBundle/contributors"
         }
     ],
+    "require": {
+        "php": ">=5.3.2",
+        "symfony/framework-bundle": "2.0.*"
+    },
+    "autoload": {
+        "psr-0": { "Mmoreramerino\\GearmanBundle": "" }
+    },
     "target-dir": "Mmoreramerino/GearmanBundle"
 }