Esempio n. 1
0
 /**
  * INTERNAL:
  * Registers an entity in the identity map.
  * Note that entities in a hierarchy are registered with the class name of
  * the root entity.
  *
  * @ignore
  *
  * @param object $entity  The entity to register.
  *
  * @return boolean TRUE if the registration was successful, FALSE if the identity of
  *                 the entity in question is already managed.
  *
  * @throws ORMInvalidArgumentException
  */
 public function addToIdentityMap($entity)
 {
     $classMetadata = $this->em->getClassMetadata(get_class($entity));
     $idHash = implode(' ', $this->entityIdentifiers[spl_object_hash($entity)]);
     if ($idHash === '') {
         throw ORMInvalidArgumentException::entityWithoutIdentity($classMetadata->name, $entity);
     }
     $className = $classMetadata->rootEntityName;
     if (isset($this->identityMap[$className][$idHash])) {
         return false;
     }
     $this->identityMap[$className][$idHash] = $entity;
     return true;
 }