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

addToIdentityMap() public method

Note that documents in a hierarchy are registered with the class name of the root document. Identifiers are serialized before being used as array keys to allow differentiation of equal, but not identical, values.
public addToIdentityMap ( object $document ) : boolean
$document object The document to register.
return boolean TRUE if the registration was successful, FALSE if the identity of the document in question is already managed.
    public function addToIdentityMap($document)
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        $id = $this->getIdForIdentityMap($document);
        if (isset($this->identityMap[$class->name][$id])) {
            return false;
        }
        $this->identityMap[$class->name][$id] = $document;
        if ($document instanceof NotifyPropertyChanged && (!$document instanceof Proxy || $document->__isInitialized())) {
            $document->addPropertyChangedListener($this);
        }
        return true;
    }
UnitOfWork