private function doMergeSingleDocumentProperty($managedCopy, $document, \ReflectionProperty $prop, array $mapping)
{
if (null === $document) {
$prop->setValue($managedCopy, null);
} elseif (!($mapping['cascade'] & ClassMetadata::CASCADE_MERGE)) {
if ($this->getDocumentState($document) == self::STATE_MANAGED) {
$prop->setValue($managedCopy, $document);
} else {
$targetClass = $this->dm->getClassMetadata(get_class($document));
$id = $this->determineDocumentId($document, $targetClass);
$proxy = $this->getOrCreateProxy($id, $targetClass->name);
$prop->setValue($managedCopy, $proxy);
$this->registerDocument($proxy, $id);
}
}
}