1
0
mirror of synced 2025-01-31 12:32:59 +03:00

#1196 DDC-3418 DDC-3419 - refactoring inherited indexes copying logic into separate private method

This commit is contained in:
Marco Pivetta 2014-11-27 18:52:03 +01:00
parent 17ec1aab77
commit 7648a3c590

View File

@ -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.
*