From 4106002344d2878ce77915aa07c742bc29942887 Mon Sep 17 00:00:00 2001 From: "Roman S. Borschel" Date: Wed, 14 Apr 2010 10:46:35 +0200 Subject: [PATCH] Small refactorings. --- lib/Doctrine/ORM/AbstractQuery.php | 4 ++-- .../ORM/Mapping/ClassMetadataFactory.php | 23 ++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index b872e9845..5acf82d0b 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -410,12 +410,12 @@ abstract class AbstractQuery throw new NonUniqueResultException; } return array_shift($result); - } else if (is_object($result)) { + }/* else if (is_object($result)) { if (count($result) > 1) { throw new NonUniqueResultException; } return $result->first(); - } + }*/ return $result; } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 99df4ccfd..13ca40840 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -203,19 +203,16 @@ class ClassMetadataFactory if ( ! $this->_initialized) { $this->_initialize(); } - + $loaded = array(); // Collect parent classes, ignoring transient (not-mapped) classes. - //TODO: Evaluate whether we can use class_parents() here. - $parentClass = $name; $parentClasses = array(); - while ($parentClass = get_parent_class($parentClass)) { + foreach (array_reverse(class_parents($name)) as $parentClass) { if ( ! $this->_driver->isTransient($parentClass)) { $parentClasses[] = $parentClass; } } - $parentClasses = array_reverse($parentClasses); $parentClasses[] = $name; // Move down the hierarchy of parent classes, starting from the topmost class @@ -231,7 +228,7 @@ class ClassMetadataFactory } $class = $this->_newClassMetadataInstance($className); - + if ($parent) { $class->setInheritanceType($parent->inheritanceType); $class->setDiscriminatorColumn($parent->discriminatorColumn); @@ -262,8 +259,8 @@ class ClassMetadataFactory } else if ($parent->isIdGeneratorTable()) { $class->getTableGeneratorDefinition($parent->tableGeneratorDefinition); } - if ($generatorType = $parent->generatorType) { - $class->setIdGeneratorType($generatorType); + if ($parent->generatorType) { + $class->setIdGeneratorType($parent->generatorType); } if ($parent->idGenerator) { $class->setIdGenerator($parent->idGenerator); @@ -282,18 +279,18 @@ class ClassMetadataFactory $eventArgs = new \Doctrine\ORM\Event\LoadClassMetadataEventArgs($class); $this->_evm->dispatchEvent(Events::loadClassMetadata, $eventArgs); } - + $this->_loadedMetadata[$className] = $class; - + $parent = $class; - + if ( ! $class->isMappedSuperclass) { array_unshift($visited, $className); } - + $loaded[] = $className; } - + return $loaded; }