diff --git a/src/Mapping/DataTarget/ManyToManyRelation.php b/src/Mapping/DataTarget/ManyToManyRelation.php index 7d8634eb..07a1c2c7 100644 --- a/src/Mapping/DataTarget/ManyToManyRelation.php +++ b/src/Mapping/DataTarget/ManyToManyRelation.php @@ -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(); @@ -109,7 +113,7 @@ protected function getMergedDataArray($valueContainer, string $getter, string $f } } } else { - return $data; + return is_array($data) ? $data : [$data]; } break; @@ -139,7 +143,7 @@ protected function getMergedDataArray($valueContainer, string $getter, string $f } } } else { - return $data; + return is_array($data) ? $data : [$data]; } break;