Bläddra i källkod

[mapping] annotation mapping changes for compatibility with symfony2

gediminasm 14 år sedan
förälder
incheckning
c0100b371c

+ 1 - 4
lib/Gedmo/Loggable/Mapping/Driver/Annotation.php

@@ -3,7 +3,6 @@
 namespace Gedmo\Loggable\Mapping\Driver;
 
 use Gedmo\Mapping\Driver\AnnotationDriverInterface,
-    Doctrine\Common\Annotations\AnnotationReader,
     Doctrine\Common\Persistence\Mapping\ClassMetadata,
     Gedmo\Exception\InvalidMappingException;
 
@@ -67,10 +66,8 @@ class Annotation implements AnnotationDriverInterface
     {
         $class = $meta->getReflectionClass();
         // class annotations
-        $classAnnotations = $this->reader->getClassAnnotations($class);
-        if (isset($classAnnotations[self::LOGGABLE])) {
+        if ($annot = $this->reader->getClassAnnotation($class, self::LOGGABLE)) {
             $config['loggable'] = true;
-            $annot = $classAnnotations[self::LOGGABLE];
             if ($annot->logEntryClass) {
                 if (!class_exists($annot->logEntryClass)) {
                     throw new InvalidMappingException("LogEntry class: {$annot->logEntryClass} does not exist.");

+ 1 - 4
lib/Gedmo/Translatable/Mapping/Driver/Annotation.php

@@ -4,7 +4,6 @@ namespace Gedmo\Translatable\Mapping\Driver;
 
 use Gedmo\Mapping\Driver\AnnotationDriverInterface,
     Doctrine\Common\Persistence\Mapping\ClassMetadata,
-    Doctrine\Common\Annotations\AnnotationReader,
     Gedmo\Exception\InvalidMappingException;
 
 /**
@@ -74,9 +73,7 @@ class Annotation implements AnnotationDriverInterface
     public function readExtendedMetadata(ClassMetadata $meta, array &$config) {
         $class = $meta->getReflectionClass();
         // class annotations
-        $classAnnotations = $this->reader->getClassAnnotations($class);
-        if (isset($classAnnotations[self::ENTITY_CLASS])) {
-            $annot = $classAnnotations[self::ENTITY_CLASS];
+        if ($annot = $this->reader->getClassAnnotation($class, self::ENTITY_CLASS)) {
             if (!class_exists($annot->class)) {
                 throw new InvalidMappingException("Translation class: {$annot->class} does not exist.");
             }

+ 2 - 6
lib/Gedmo/Tree/Mapping/Driver/Annotation.php

@@ -3,7 +3,6 @@
 namespace Gedmo\Tree\Mapping\Driver;
 
 use Gedmo\Mapping\Driver\AnnotationDriverInterface,
-    Doctrine\Common\Annotations\AnnotationReader,
     Doctrine\Common\Persistence\Mapping\ClassMetadata,
     Gedmo\Exception\InvalidMappingException;
 
@@ -114,16 +113,13 @@ class Annotation implements AnnotationDriverInterface
     public function readExtendedMetadata(ClassMetadata $meta, array &$config) {
         $class = $meta->getReflectionClass();
         // class annotations
-        $classAnnotations = $this->reader->getClassAnnotations($class);
-        if (isset($classAnnotations[self::TREE])) {
-            $annot = $classAnnotations[self::TREE];
+        if ($annot = $this->reader->getClassAnnotation($class, self::TREE)) {
             if (!in_array($annot->type, $this->strategies)) {
                 throw new InvalidMappingException("Tree type: {$annot->type} is not available.");
             }
             $config['strategy'] = $annot->type;
         }
-        if (isset($classAnnotations[self::CLOSURE])) {
-            $annot = $classAnnotations[self::CLOSURE];
+        if ($annot = $this->reader->getClassAnnotation($class, self::CLOSURE)) {
             if (!class_exists($annot->class)) {
                 throw new InvalidMappingException("Tree closure class: {$annot->class} does not exist.");
             }