diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 71c57a78e..7414399aa 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -175,22 +175,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory $class->setPrimaryTable($parent->table); } - if ($parent && $parent->isMappedSuperclass) { - //Copy the table indices from the parent - - $indexTypes = array ('uniqueConstraints', 'indexes'); - - foreach ($indexTypes as $indexType) { - if (isset($parent->table[$indexType])) { - foreach ($parent->table[$indexType] as $indexName => $index) { - if (isset($class->table[$indexType][$indexName])) { - continue; // Let the inheriting table override indices - } - - $class->table[$indexType][$indexName] = $index; - } - } - } + if ($parent) { + $this->addInheritedIndexes($class, $parent); } if ($parent && $parent->cache) { @@ -433,6 +419,33 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory } } + /** + * Copy the table indices from the parent class superclass to the child class + * + * @param ClassMetadata $subClass + * @param ClassMetadata $parentClass + * + * @return void + */ + private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass) + { + if (! $parentClass->isMappedSuperclass) { + return; + } + + foreach (array('uniqueConstraints', 'indexes') as $indexType) { + if (isset($parentClass->table[$indexType])) { + foreach ($parentClass->table[$indexType] as $indexName => $index) { + if (isset($subClass->table[$indexType][$indexName])) { + continue; // Let the inheriting table override indices + } + + $subClass->table[$indexType][$indexName] = $index; + } + } + } + } + /** * Adds inherited named queries to the subclass mapping. *