Skip to content

Commit

Permalink
Added forwards compatibility for Doctrine 2.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Parsiegla committed Apr 18, 2012
1 parent c23acd1 commit c2da2b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Module/WorkerClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -143,4 +143,4 @@ public function __toCache()
return $dump;
}

}
}
18 changes: 14 additions & 4 deletions Service/GearmanCacheLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c2da2b7

Please sign in to comment.