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

getOwningDocument() public method

If a top-level document is provided, that same document will be returned. For an embedded document, we will walk through parent associations until we find a top-level document.
public getOwningDocument ( object $document ) : object
$document object
return object
    public function getOwningDocument($document)
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        while ($class->isEmbeddedDocument) {
            $parentAssociation = $this->getParentAssociation($document);
            if (!$parentAssociation) {
                throw new \UnexpectedValueException('Could not determine parent association for ' . get_class($document));
            }
            list(, $document, ) = $parentAssociation;
            $class = $this->dm->getClassMetadata(get_class($document));
        }
        return $document;
    }
UnitOfWork