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:
parent
f0d2e8d150
commit
2a81adc1fc
@ -189,8 +189,8 @@ class ObjectHydrator extends AbstractHydrator
|
|||||||
$relation = $class->associationMappings[$fieldName];
|
$relation = $class->associationMappings[$fieldName];
|
||||||
$value = $class->reflFields[$fieldName]->getValue($entity);
|
$value = $class->reflFields[$fieldName]->getValue($entity);
|
||||||
|
|
||||||
if ($value === null) {
|
if ($value === null || is_array($value)) {
|
||||||
$value = new ArrayCollection;
|
$value = new ArrayCollection((array) $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $value instanceof PersistentCollection) {
|
if ( ! $value instanceof PersistentCollection) {
|
||||||
|
Loading…
Reference in New Issue
Block a user