destroy entity.

@param   Entity  $entity
969369
public function destroy(Entity $entity)
    {
        if ($entity->isExists()) {

            // enable logical delete ?
            if ($entity->hasAttribute('active')) {
                $attributes = [];
                $attributes['active'] = 0;
                if ($entity->hasAttribute('deleted_at')) $attributes['deleted_at'] = time();
                $this->update($attributes, $entity->getPrimaryValue());
            } else {
                $this->delete($entity->getPrimaryValue());
            }
        }
    }
642714
public function delete($id)
    {
        $this->beforeDelete($id);
        $this->entity->delete($id);
        $this->afterDelete($id);
    }
889019
public final function remove(Entity $entity): int
    {
        $primaryValue = $entity->getPrimaryValue();
        if ($primaryValue === null) {
            throw new InvalidValueException('Primary value not found on entity for delete action!');
        }

        return $this->removeAll($primaryValue);
    }
427746
public function save($entity)
    {
        $this
            ->objectManager
            ->persist($entity);

        $this
            ->objectManager
            ->flush($entity);
    }
24512
public function handle(Entity $entity)
    {
        // We will initially check if the model is using soft deletes. If so,
        // the attribute values will remain untouched as they should sill
        // be available till the entity is truly deleted from database.
        if (in_array(SoftDeletes::class, class_uses_recursive(get_class($entity))) && ! $entity->isForceDeleting()) {
            return;
        }

        foreach ($entity->getEntityAttributes() as $attribute) {
            if ($entity->relationLoaded($relation = $attribute->getAttribute('slug'))
                && ($values = $entity->getRelationValue($relation)) && ! $values->isEmpty()) {
                // Calling the `destroy` method from the given $type model class name
                // will finally delete the records from database if any was found.
                // We'll just provide an array containing the ids to be deleted.
                forward_static_call_array([$attribute->getAttribute('type'), 'destroy'], [$values->pluck('id')->toArray()]);
            }
        }
    }
316265
public function delete($entity)
    {
        $query = $this->db->table($entity->definition()->getName());
        $primary = $entity->id();
        if (isset($this->objects[$entity->definition()->getName()][base64_encode(serialize($primary))])) {
            foreach ($primary as $k => $v) {
                $query->filter($k, $v);
            }
            $query->delete();
            unset($this->objects[$entity->definition()->getName()][base64_encode(serialize($primary))]);
        }
    }
255254
@Override
	public void delete(Object entity) {
		if (entity == null) {
			throw new IllegalArgumentException("'entity' must not be [" + entity + "]");
		}
		
		if (operation != Log.Operation.GET) {
			throw new IllegalStateException("Log [" + operation + "] -> ["
					+ Log.Operation.DELETE
					+ "] is not allowed: previous operation must be ["
					+ Log.Operation.GET + "]");
		}
		
		operation = Log.Operation.DELETE;
	}
371586
public function deleteEntity(\Dlin\Saasu\Entity\EntityBase $entity)
    {
        $this->throttler->throttle();
        $uid = $entity->uid;
        if (intval($uid) > 0) { //load data from remote service
            $url = $this->_buildURL($entity->getName(), array('uid' => $uid));

            $response = $this->client->delete($url)->send();

            //check exception in response
            $this->checkException($response);
        }
        return $this;

    }
858144
public function remove($entity)
    {
        $idAccessorRegistry = $this->unitOfWork->getEntityRegistry()->getIdAccessorRegistry();
        $entityId           = $idAccessorRegistry->getEntityId($entity);

        $this->updateMap();

        if (!in_array($entityId, $this->map)) {
            throw new EntityNotFoundException;
        }

        $colJoinName = $this->relation->colJoinName();
        $mapObject   = $this->mapRepository->findOne()->with($colJoinName, Operator::EQUAL, $entityId)->getItem();
        $this->mapRepository->remove($mapObject);
        $this->map = array_diff($this->map, [$entityId]);
    }
505997
public function unregisterReconstitutedEntity($entity)
    {
        if ($this->reconstitutedEntities->contains($entity)) {
            $this->reconstitutedEntities->detach($entity);
            unset($this->reconstitutedEntitiesData[$this->getIdentifierByObject($entity)]);
        }
    }
202655
public function remove(EntityRemoved $event)
    {
        $entity = $event->getEntity();
        $collection = $event->getCollection();
        $this->deleteRelation($entity, $collection);
    }
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;
        }
    }
598737
def unregister(self, entity_class, entity):
        
        EntityState.release(entity, self)
        self.__entity_set_map[entity_class].remove(entity)
520440
public function delete($entity)
    {
        if (($entity instanceof Model) === false) {
            $entity = $this->find($entity);
        }

        if ($entity->delete()) {
            $this->flushCache();

            return true;
        }

        return false;
    }
258211
private function detachAndPersist($entity)
    {
        $this->em->detach($entity);
        $this->em->persist($entity);
    }
1192853
public function delete ($Model)
    {
        $entity   = $Model->getEntity();
        $entityId = $entity->getId();

        // Clear cache first
        if (isset($this->cache[$entityId])) {
            unset($this->cache[$entityId]);
        }

        $this->em->remove($entity);
        $this->em->flush();
    }
1170886
public function deleteAddresses($entity)
    {
        // clear addresses
        if ($entity->getAccountAddresses()) {
            foreach ($entity->getAccountAddresses() as $accountAddresses) {
                $this->em->remove($accountAddresses->getAddress());
                $this->em->remove($accountAddresses);
            }
        }
    }