1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Correcting ObjectHydrator logic: if an array is a default value for a collection-valued property, it should be cast to a Collection

This commit is contained in:
Marco Pivetta 2015-04-03 15:28:53 +01:00
parent f0d2e8d150
commit 2a81adc1fc

View File

@ -189,8 +189,8 @@ class ObjectHydrator extends AbstractHydrator
$relation = $class->associationMappings[$fieldName];
$value = $class->reflFields[$fieldName]->getValue($entity);
if ($value === null) {
$value = new ArrayCollection;
if ($value === null || is_array($value)) {
$value = new ArrayCollection((array) $value);
}
if ( ! $value instanceof PersistentCollection) {