#1196 DDC-3418 DDC-3419 - refactoring inherited indexes copying logic into separate private method
This commit is contained in:
parent
17ec1aab77
commit
7648a3c590
@ -175,22 +175,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
|||||||
$class->setPrimaryTable($parent->table);
|
$class->setPrimaryTable($parent->table);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parent && $parent->isMappedSuperclass) {
|
if ($parent) {
|
||||||
//Copy the table indices from the parent
|
$this->addInheritedIndexes($class, $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 && $parent->cache) {
|
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.
|
* Adds inherited named queries to the subclass mapping.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user