Browse Source

split metadataExtension by objectManager classes, this fix issue when using both ORM and ODM at the same time

jaugustin 14 years ago
parent
commit
2293432b93
1 changed files with 5 additions and 4 deletions
  1. 5 4
      lib/Gedmo/Mapping/MappedEventSubscriber.php

+ 5 - 4
lib/Gedmo/Mapping/MappedEventSubscriber.php

@@ -39,7 +39,7 @@ abstract class MappedEventSubscriber implements EventSubscriber
      *
      * @var Gedmo\Mapping\ExtensionMetadataFactory
      */
-    private $extensionMetadataFactory;
+    private $extensionMetadataFactory = array();
 
     /**
      * List of event adapters used for this listener
@@ -105,13 +105,14 @@ abstract class MappedEventSubscriber implements EventSubscriber
      */
     public function getExtensionMetadataFactory(ObjectManager $objectManager)
     {
-        if (null === $this->extensionMetadataFactory) {
-            $this->extensionMetadataFactory = new ExtensionMetadataFactory(
+        $class = get_class($objectManager);
+        if (!isset($this->extensionMetadataFactory[$class])) {
+            $this->extensionMetadataFactory[$class] = new ExtensionMetadataFactory(
                 $objectManager,
                 $this->getNamespace()
             );
         }
-        return $this->extensionMetadataFactory;
+        return $this->extensionMetadataFactory[$class];
     }
 
     /**