Skip to content

Commit

Permalink
Fix for ManyToOne Relation
Browse files Browse the repository at this point in the history
  • Loading branch information
joschi127 committed May 14, 2016
1 parent 68a8a73 commit 15773d1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions EventListener/LoadORMMetadataSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,17 @@ protected function setAssociationMappings(ClassMetadataInfo $metadata, $configur
if (in_array($parentClass, $configuration->getMetadataDriverImpl()->getAllClassNames())) {
$configuration->getMetadataDriverImpl()->loadMetadataForClass($parentClass, $parentMetadata);

foreach ($parentMetadata->getAssociationMappings() as $name => $mapping) {
if ($this->typeIsRelation($mapping['type'])) {
// update sourceEntity of association mapping
if(isset($mapping['sourceEntity']) && $mapping['sourceEntity'] == $parentClass) {
$mapping['sourceEntity'] = $class;
}

// add association mapping for actually used class
$metadata->associationMappings[$name] = $mapping;
if ($this->classIsOverridden($parentClass)) {
foreach ($parentMetadata->getAssociationMappings() as $name => $mapping) {
//if ($this->typeIsRelation($mapping['type'])) {
// update sourceEntity of association mapping
if (isset($mapping['sourceEntity']) && $mapping['sourceEntity'] == $parentClass) {
$mapping['sourceEntity'] = $class;
}

// add association mapping for actually used class
$metadata->associationMappings[$name] = $mapping;
//}
}
}
}
Expand Down Expand Up @@ -262,9 +264,9 @@ protected function unsetAssociationMappings(ClassMetadataInfo $metadata)
if ($this->classIsOverridden($metadata->getName())) {
// remove all association mappings from mapped super classes, which are not allowed to have association mappings
foreach ($metadata->getAssociationMappings() as $name => $mapping) {
if ($this->typeIsRelation($mapping['type'])) {
//if ($this->typeIsRelation($mapping['type'])) {
unset($metadata->associationMappings[$name]);
}
//}
}
}
}
Expand Down

0 comments on commit 15773d1

Please sign in to comment.