Doctrine\ODM\MongoDB\UnitOfWork::cascadeMerge PHP Method

cascadeMerge() private method

Cascades a merge operation to associated documents.
private cascadeMerge ( object $document, object $managedCopy, array &$visited )
$document object
$managedCopy object
$visited array
    private function cascadeMerge($document, $managedCopy, array &$visited)
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        $associationMappings = array_filter($class->associationMappings, function ($assoc) {
            return $assoc['isCascadeMerge'];
        });
        foreach ($associationMappings as $assoc) {
            $relatedDocuments = $class->reflFields[$assoc['fieldName']]->getValue($document);
            if ($relatedDocuments instanceof Collection || is_array($relatedDocuments)) {
                if ($relatedDocuments === $class->reflFields[$assoc['fieldName']]->getValue($managedCopy)) {
                    // Collections are the same, so there is nothing to do
                    continue;
                }
                foreach ($relatedDocuments as $relatedDocument) {
                    $this->doMerge($relatedDocument, $visited, $managedCopy, $assoc);
                }
            } elseif ($relatedDocuments !== null) {
                $this->doMerge($relatedDocuments, $visited, $managedCopy, $assoc);
            }
        }
    }
UnitOfWork