Unregisters data for a reconstituted object

@param object $entity
@return void
505997
public function unregisterReconstitutedEntity($entity)
    {
        if ($this->reconstitutedEntities->contains($entity)) {
            $this->reconstitutedEntities->detach($entity);
            unset($this->reconstitutedEntitiesData[$this->getIdentifierByObject($entity)]);
        }
    }
522955
private function unregister() {
        if ($this->db) {
            $this->db->recordset_closed($this);
            $this->db = null;
        }
    }
1042982
public function registerEntity(&$entity)
    {
        $this->unstashEntity($entity);

        $className    = $this->getClassName($entity);
        $objectHashId = $this->getObjectHashId($entity);
        $entityId     = $this->getEntityId($entity);

        if (!isset($this->entities[$className])) {
            $this->entities[$className] = [];
        }

        if (isset($this->entities[$className][$entityId])) {
            // Change the reference of the input entity to the one that's already registered
            $entity = $this->entities[$className][$entityId];
        } else {
            // Register this entity
            $this->changeTracker->startTracking($entity);
            $this->entities[$className][$entityId] = $entity;
            $this->entityStates[$objectHashId]     = EntityStates::REGISTERED;
        }
    }
134054
public function unregister($name)
    {
        if (!isset($this->registry[$name])) {
            throw new Exception('Object with name "'.$name.'" is not registered');
        }

        $object = $this->registry[$name];
        unset($this->registry[$name]);

        return $object;
    }
1170886
public function deleteAddresses($entity)
    {
        // clear addresses
        if ($entity->getAccountAddresses()) {
            foreach ($entity->getAccountAddresses() as $accountAddresses) {
                $this->em->remove($accountAddresses->getAddress());
                $this->em->remove($accountAddresses);
            }
        }
    }
1326792
private function resetCacheEntity()
    {
        if (null !== $this->_entity) {
            $this->_em->detach($this->_entity);
            $this->_entity = null;
        }
    }
1112687
protected function delete()
    {
        foreach ($this->scheduledForDeletion as $objectHashId => $entity) {
            $dataMapper = $this->getDataMapper($this->entityRegistry->getClassName($entity));
            $dataMapper->delete($entity);

            // Order here matters
            $this->detach($entity);
            $this->entityRegistry->setState($entity, EntityStates::DEQUEUED);
        }
    }
875087
public function scheduleForDelete($entity)
    {
        $oid = spl_object_id($entity);

        if (isset($this->entityInsertions[$oid])) {
            if ($this->isInIdentityMap($entity)) {
                $this->removeFromIdentityMap($entity);
            }

            unset($this->entityInsertions[$oid], $this->entityStates[$oid]);

            return; // entity has not been persisted yet, so nothing more to do.
        }

        if (! $this->isInIdentityMap($entity)) {
            return;
        }

        $this->removeFromIdentityMap($entity);

        unset($this->entityUpdates[$oid]);

        if (! isset($this->entityDeletions[$oid])) {
            $this->entityDeletions[$oid] = $entity;
            $this->entityStates[$oid]    = self::STATE_REMOVED;
        }
    }
938816
public function deregisterEntity($entity)
    {
        $entityState = $this->getEntityState($entity);
        unset($this->aggregateRootChildren[$this->getObjectHashId($entity)]);

        if ($entityState == EntityStates::QUEUED || $entityState == EntityStates::REGISTERED) {
            $className                         = $this->getClassName($entity);
            $objectHashId                      = $this->getObjectHashId($entity);
            $entityId                          = $this->getEntityId($entity);
            $this->entityStates[$objectHashId] = EntityStates::UNREGISTERED;
            unset($this->entities[$className][$entityId]);
            $this->changeTracker->stopTracking($entity);
        }
    }
872342
public function delete($entity)
    {
        $this->_em->remove($entity);
        $this->_em->flush($entity);
    }
601131
protected function removeEntity (...$entities) : void
    {
        try
        {
            $entities = \array_filter($entities);

            if (empty($entities))
            {
                return;
            }

            $entityManager = $this->getEntityManager();
            \array_map([$entityManager, "remove"], $entities);
            $entityManager->flush();
        }
        catch (ForeignKeyConstraintViolationException $foreignKeyException)
        {
            throw new EntityRemovalBlockedException(
                $entities,
                "Can't remove entities as a foreign key constraint failed.",
                $foreignKeyException
            );
        }
    }
144108
public function remove(Entity $entity) {
    if (method_exists($entity,'remove')) {
      $entity->remove();
    }
    $this->_em->remove($entity);
    
    return $this;
  }
317799
public function offsetUnset($object)
       {
            if (parent::contains($object)) {
                parent::offsetUnset($object);
                $index = array_search(spl_object_hash($object), $this->map, true);
                unset($this->map[$index]);
            }
       }
1336543
public function commit($entity)
    {
        switch ($entity->getEntityState()) {
            case AnDomain::STATE_NEW:
                $operation = AnDomain::OPERATION_INSERT;
                $command = 'insert';
                break;
            case AnDomain::STATE_MODIFIED :
                //get all the updated serializable property/value pairs
                $operation = AnDomain::OPERATION_UPDATE;
                $command = 'update';
                break;
            case  AnDomain::STATE_DELETED :
                $operation = AnDomain::OPERATION_DELETE;
                $command = 'delete';
                break;
            default :
                return;
        }

        $context = $this->getCommandContext();
        $context->operation = $operation;
        $context->entity = $entity;
        $context->data = array();
        $store = $this->getStore();

        if ($context->result = $this->getCommandChain()->run('before.'.$command, $context) !== false) {
            $context->data = $entity->getAffectedRowData();

            switch ($operation) {
                case(AnDomain::OPERATION_INSERT) :
                    if (!count($context->data)) {
                        throw new AnDomainRepositoryException('Attempting to store an entity with empty data');
                    }

                    $context->result = $store->insert($this, $context->data);
                    break;

                case(AnDomain::OPERATION_UPDATE) :
                case(AnDomain::OPERATION_DELETE) :

                    $keys = $this->_description->getIdentityProperty()->serialize($entity->getIdentityId());
                    $keys = array($this->_description->getIdentityProperty()->getName() => $entity->getIdentityId());

                    if ($operation & AnDomain::OPERATION_UPDATE) {
                        $context->result = count($context->data) ? $this->update($context->data, $keys) : true;
                    } else {
                        $context->result = $this->destroy($keys);
                    }
            }

            $this->getCommandChain()->run('after.'.$command, $context);
        }

        return    $context->result !== false;
    }
258211
private function detachAndPersist($entity)
    {
        $this->em->detach($entity);
        $this->em->persist($entity);
    }
530216
public function clear($entity)
    {
        /**
         * @var ObjectManager $objectManager
         */
        $objectManager = $this
            ->get('elcodi.provider.manager')
            ->getManagerByEntityNamespace(get_class($entity));

        $objectManager->clear($entity);

        return $this;
    }
741441
protected function registerDirty(PersistentObject $object) {
    $key = $object->getOID()->__toString();
    // if it was a new or deleted object, we return immediatly
    if (isset($this->newObjects[$key]) || isset($this->deletedObjects[$key])) {
      return $object;
    }
    if (self::$isDebugEnabled) {
      self::$logger->debug("Register dirty object: ".$key);
    }
    $this->dirtyObjects[$key] = $object;
    return $object;
  }