Skip to content

Commit

Permalink
Merge pull request Sylius#7367 from venyii/fix-mappedsuperclass-subsc…
Browse files Browse the repository at this point in the history
…riber

[ResourceBundle] Prevent overriding existing association mappings
  • Loading branch information
pjedrzejewski committed Jan 30, 2017
2 parents 96353b2 + f1150d6 commit bfc782c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Expand Up @@ -97,7 +97,7 @@ private function setAssociationMappings(ClassMetadataInfo $metadata, $configurat

if ($parentMetadata->isMappedSuperclass) {
foreach ($parentMetadata->associationMappings as $key => $value) {
if ($this->hasRelation($value['association'])) {
if ($this->isRelation($value['association']) && !isset($metadata->associationMappings[$key])) {
$metadata->associationMappings[$key] = $value;
}
}
Expand All @@ -115,18 +115,18 @@ private function unsetAssociationMappings(ClassMetadataInfo $metadata)
}

foreach ($metadata->associationMappings as $key => $value) {
if ($this->hasRelation($value['association'])) {
if ($this->isRelation($value['association'])) {
unset($metadata->associationMappings[$key]);
}
}
}

/**
* @param $type
* @param string $type
*
* @return bool
*/
private function hasRelation($type)
private function isRelation($type)
{
return in_array(
$type,
Expand Down
Expand Up @@ -96,7 +96,7 @@ private function setAssociationMappings(ClassMetadataInfo $metadata, $configurat

if ($parentMetadata->isMappedSuperclass) {
foreach ($parentMetadata->getAssociationMappings() as $key => $value) {
if ($this->hasRelation($value['type'])) {
if ($this->isRelation($value['type']) && !isset($metadata->associationMappings[$key])) {
$metadata->associationMappings[$key] = $value;
}
}
Expand All @@ -114,18 +114,18 @@ private function unsetAssociationMappings(ClassMetadataInfo $metadata)
}

foreach ($metadata->getAssociationMappings() as $key => $value) {
if ($this->hasRelation($value['type'])) {
if ($this->isRelation($value['type'])) {
unset($metadata->associationMappings[$key]);
}
}
}

/**
* @param $type
* @param string $type
*
* @return bool
*/
private function hasRelation($type)
private function isRelation($type)
{
return in_array(
$type,
Expand Down

0 comments on commit bfc782c

Please sign in to comment.