Skip to content

Commit

Permalink
Related to #160 . is not type saved and therefore it can break upon b…
Browse files Browse the repository at this point in the history
…eing returned if the type is not array (#160)
  • Loading branch information
florian25686 authored Feb 2, 2022
1 parent 0fe7e51 commit e87f8a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Mapping/DataTarget/ManyToManyRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ protected function doAssignData($valueContainer, $fieldName, $data)
*/
protected function getMergedDataArray($valueContainer, string $getter, string $fieldType, $data): array
{
if (null === $data) {
return [];
}

$currentData = [];
if ($this->overwriteMode == self::OVERWRITE_MODE_MERGE) {
$hideUnpublished = DataObject::getHideUnpublished();
Expand All @@ -109,7 +113,7 @@ protected function getMergedDataArray($valueContainer, string $getter, string $f
}
}
} else {
return $data;
return is_array($data) ? $data : [$data];
}
break;

Expand Down Expand Up @@ -139,7 +143,7 @@ protected function getMergedDataArray($valueContainer, string $getter, string $f
}
}
} else {
return $data;
return is_array($data) ? $data : [$data];
}

break;
Expand Down

0 comments on commit e87f8a5

Please sign in to comment.