Documentation : fix table prefix with STI
If an Entity use STI, it gets its table name from the parent class. In this case, we need to check that the class is the root class of the hierarchy when adding prefix, otherwise children class are prefixed twice.
This commit is contained in:
parent
a13143b1ac
commit
1661d96b92
@ -39,7 +39,11 @@ appropriate autoloaders.
|
||||
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
|
||||
{
|
||||
$classMetadata = $eventArgs->getClassMetadata();
|
||||
$classMetadata->setTableName($this->prefix . $classMetadata->getTableName());
|
||||
|
||||
if (!$classMetadata->isInheritanceTypeSingleTable() || $classMetadata->getName() === $classMetadata->rootEntityName) {
|
||||
$classMetadata->setTableName($this->prefix . $classMetadata->getTableName());
|
||||
}
|
||||
|
||||
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
|
||||
if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY) {
|
||||
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
|
||||
|
Loading…
Reference in New Issue
Block a user