Commit 846e0bfd authored by romanb's avatar romanb

[2.0] Better fix for #2478.

parent e0012f07
......@@ -138,18 +138,30 @@ class ObjectHydrator extends AbstractHydrator
$class = $this->_ce[get_class($entity)];
$relation = $class->associationMappings[$name];
$pColl = new PersistentCollection(
$this->_em,
$this->_ce[$relation->targetEntityName],
new ArrayCollection
);
$value = $class->reflFields[$name]->getValue($entity);
if ($value === null) {
$value = new ArrayCollection;
}
if ($value instanceof ArrayCollection) {
$value = new PersistentCollection(
$this->_em,
$this->_ce[$relation->targetEntityName],
$value
);
$value->setOwner($entity, $relation);
} else {
// Is already PersistentCollection.
$value->clear();
$value->setDirty(false);
$value->setInitialized(true);
}
$pColl->setOwner($entity, $relation);
$class->reflFields[$name]->setValue($entity, $pColl);
$this->_uow->setOriginalEntityProperty($oid, $name, $pColl);
$this->_initializedCollections[$oid . $name] = $pColl;
$class->reflFields[$name]->setValue($entity, $value);
$this->_uow->setOriginalEntityProperty($oid, $name, $value);
$this->_initializedCollections[$oid . $name] = $value;
return $pColl;
return $value;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment