浏览代码

[DoctrineBridge] Optimized the mapping drivers

Christophe Coevoet 14 年之前
父节点
当前提交
5d17b9207c

+ 16 - 1
src/Symfony/Bridge/Doctrine/Mapping/Driver/XmlDriver.php

@@ -48,7 +48,22 @@ class XmlDriver extends BaseXmlDriver
 
     public function isTransient($className)
     {
-        return !in_array($className, $this->getAllClassNames());
+        if (null === $this->_classCache) {
+            $this->initialize();
+        }
+
+        // The mapping is defined in the global mapping file
+        if (isset($this->_classCache[$className])) {
+            return false;
+        }
+
+        try {
+            $this->_findMappingFile($className);
+
+            return false;
+        } catch (MappingException $e) {
+            return true;
+        }
     }
 
     public function getAllClassNames()

+ 16 - 1
src/Symfony/Bridge/Doctrine/Mapping/Driver/YamlDriver.php

@@ -48,7 +48,22 @@ class YamlDriver extends BaseYamlDriver
 
     public function isTransient($className)
     {
-        return !in_array($className, $this->getAllClassNames());
+        if (null === $this->_classCache) {
+            $this->initialize();
+        }
+
+        // The mapping is defined in the global mapping file
+        if (isset($this->_classCache[$className])) {
+            return false;
+        }
+
+        try {
+            $this->_findMappingFile($className);
+
+            return false;
+        } catch (MappingException $e) {
+            return true;
+        }
     }
 
     public function getAllClassNames()