Doctrine\ORM\UnitOfWork::addToIdentityMap PHP Method

addToIdentityMap() public method

Note that entities in a hierarchy are registered with the class name of the root entity.
public addToIdentityMap ( object $entity ) : boolean
$entity object The entity to register.
return boolean TRUE if the registration was successful, FALSE if the identity of the entity in question is already managed.
    public function addToIdentityMap($entity)
    {
        $classMetadata = $this->em->getClassMetadata(get_class($entity));
        $idHash = implode(' ', $this->entityIdentifiers[spl_object_hash($entity)]);
        if ($idHash === '') {
            throw new InvalidArgumentException("The given entity has no identity.");
        }
        $className = $classMetadata->rootEntityName;
        if (isset($this->identityMap[$className][$idHash])) {
            return false;
        }
        $this->identityMap[$className][$idHash] = $entity;
        if ($entity instanceof NotifyPropertyChanged) {
            $entity->addPropertyChangedListener($this);
        }
        return true;
    }