Permanently deletes the entity instance

@throws DeleteException
@throws \Doctrine\DBAL\DBALException
@return $this
977572
public function delete()
    {
        if (!$this->hasId()) {
            throw new DeleteException('ID not set - did you call find($id) before delete()?');
        }

        if (!$this->isDeletable()) {
            throw new DeleteException('Permission denied: Entity can not be deleted');
        }

        $this->transactional(function () {
            $this->forceDelete();
        });

        return $this;
    }
325461
public function delete()
    {
        DB::beginTransaction();

        try {
            LaravelEvent::fire(static::$name.'.deleting', $this);
            $this->beforeDelete();
            $return = parent::delete();
            $this->afterDelete($return);
            LaravelEvent::fire(static::$name.'.deleted', $this);

            DB::commit();
        } catch (\Exception $e) {
            DB::rollBack();
            throw $e;
        }

        return $return;
    }
273603
public function deleteAll() {
        $instances = $this->read();

        $ids = [];

        foreach ($instances as $instance) {
            $ids[] = $instance['id'];
        }

        if (count($ids) > 0) {
            $this->batchDelete($ids);
        }

        return $this;
    }
1163775
public function remove($entity)
    {
        $key = get_class($entity).'::'.$entity->getId();
        $this->getCache()->erase($key);
        return $this;
    }
226327
public function delete() {
        $sql = new Sql();
        $transaction = Database::instance()->db()->inTransaction();

        if (!$transaction) {
            Database::instance()->db()->beginTransaction();
        }

        foreach ($this->_fields as $field) {
            if ($field->primary == false) {
                if ($field->foreign != null) {
                    switch ($field->foreign->type()) {
                        case ForeignKey::ONE_TO_ONE :
                            /** if it's a one to one relation, we delete the linked Entity */
                            if ($field->value != null) {
                                if (gettype($field->value) != 'object') {
                                    if ($field->foreign->type() == Builder::JOIN_INNER) {
                                        throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be an Entity');
                                    }
                                }
                                if (get_class($field->value) != 'System\Collection\Collection') {
                                    throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be an Entity');
                                }

                                $field->value->delete();
                            }
                            break;

                        case ForeignKey::MANY_TO_ONE :
                            if ($field->value != null) {
                                if ($field->foreign->belong() == ForeignKey::COMPOSITION) {
                                    if (gettype($field->value) != 'object') {
                                        throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be an Entity');
                                    }
                                    if (get_class($field->value) != 'System\Collection\Collection') {
                                        throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be an Entity');
                                    }

                                    $field->value->delete();
                                }
                            }
                            break;

                        case ForeignKey::ONE_TO_MANY :
                            if ($field->value != null) {
                                if (gettype($field->value) != 'object') {
                                    throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be a Collection');
                                }
                                if (get_class($field->value) != 'System\Collection\Collection') {
                                    throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be a Collection');
                                }

                                if ($field->foreign->belong() == ForeignKey::COMPOSITION) {
                                    /** @var $entity \Gcs\Framework\Core\Orm\Entity\Entity */
                                    foreach ($field->value as $entity) {
                                        if ($entity != null) {
                                            $field->value->delete();
                                        }
                                    }
                                }
                            }
                            break;

                        case ForeignKey::MANY_TO_MANY :
                            /** Here we must delete from the referenced table and the relation table too */
                            if ($field->value != null) {
                                if (gettype($field->value) != 'object') {
                                    throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be a Collection');
                                }
                                if (get_class($field->value) != 'System\Collection\Collection') {
                                    throw new MissingEntityException('The field "' . $field->name . '" in "' . $this->_name . '" must be a Collection');
                                }

                                if ($field->foreign->belong() == ForeignKey::COMPOSITION) {
                                    $currentEntity = $field->foreign->entity();
                                    $currentField = $field->foreign->field();
                                    $referenceEntity = $field->foreign->referenceEntity();
                                    $referenceField = $field->foreign->referenceField();

                                    $current = strtolower($currentEntity . $currentField);
                                    $reference = strtolower($referenceEntity . $referenceField);
                                    $table = [$current, $reference];
                                    sort($table, SORT_STRING);
                                    $table = ucfirst($table[0] . $table[1]);

                                    $sql = new Sql();
                                    $sql->query('orm-delete-many', 'DELETE FROM ' . $table . ' WHERE ' . $this->name() . '_' . $field->foreign->referenceField() . ' = ' . $this->_fields[$this->_primary]);
                                    $sql->fetch('orm-delete-many');

                                    /** @var $entity \Gcs\Framework\Core\Orm\Entity\Entity */
                                    foreach ($field->value as $entity) {
                                        if ($entity != null) {
                                            $field->value->delete();
                                        }
                                    }
                                }
                            }
                            break;
                    }
                }
                else {
                    switch ($field->type) {
                        case Field::FILE :
                            if ($field->unique) {
                                $field->value->delete();
                            }
                            break;
                    }
                }
            }
        }

        $query = 'DELETE FROM ' . $this->_name . ' WHERE ' . $this->_fields[$this->_primary]->name . ' = ' . $this->_fields[$this->_primary]->value;

        $sql->query('delete_' . $this->_name . '_' . $this->_token, $query);
        $sql->fetch('delete_' . $this->_name . '_' . $this->_token, Sql::PARAM_FETCHDELETE);

        if (!$transaction) {
            Database::instance()->db()->commit();
        }
    }
1266603
public function delete()
	{

		$dbr = wfGetDB( DB_MASTER );

		$dbr->delete( static::$table,
			array( 'id' => $this->id )
		);

		$dbr->commit();

	}
632060
public function delete()
    {
        $this->getUser()->post('source/delete', array('id' => $this->getId()));
        $this->setStatus(self::STATUS_DELETED);

        return $this;
    }
890069
public function delete() {
    if ($this->isNew()) {
      throw new \Exception('ID is not setted for Delete');
    }

    $this->db()->delete($this->table, $this->identifier());
    $this->isDeleted = TRUE;

    return $this;
  }
516068
public function delete(){
        return X::app()->db->table(self::tableName())->delete([self::$pk=>$this->{self::$pk}]);
    }
101290
public function delete()
    {
        if ($this->state === State::PENDING) {
            throw new LogicException('You cannot delete pending models');
        } elseif ($this->state === State::SAVED) {
            $this->state = State::DELETED;
        }

        return $this;
    }
90490
public function clear()
    {
        $this->entityPersisters               =
        $this->collectionPersisters           =
        $this->eagerLoadingEntities           =
        $this->identityMap                    =
        $this->entityIdentifiers              =
        $this->originalEntityData             =
        $this->entityChangeSets               =
        $this->entityStates                   =
        $this->scheduledForSynchronization    =
        $this->entityInsertions               =
        $this->entityUpdates                  =
        $this->entityDeletions                =
        $this->collectionDeletions            =
        $this->collectionUpdates              =
        $this->extraUpdates                   =
        $this->readOnlyObjects                =
        $this->visitedCollections             =
        $this->nonCascadedNewDetectedEntities =
        $this->orphanRemovals                 = [];
    }
1346392
@Transactional
    public void delete(E entity) {
        if (entityManager.contains(entity)) {
            entityManager.remove(entity);
        } else {
            // could be a delete on a transient instance
            E entityRef = entityManager.getReference(type, entity.getId());

            if (entityRef != null) {
                entityManager.remove(entityRef);
            } else {
                log.warning("Attempt to delete an instance that is not present in the database: " + entity);
            }
        }
    }
740967
final public function remove(BaseEntityInterface $entity, $flush = false): self
    {
        $this->_em->remove($entity);

        if (true === $flush) {
            $this->_em->flush();
        }

        return $this;
    }
530216
public function clear($entity)
    {
        /**
         * @var ObjectManager $objectManager
         */
        $objectManager = $this
            ->get('elcodi.provider.manager')
            ->getManagerByEntityNamespace(get_class($entity));

        $objectManager->clear($entity);

        return $this;
    }
129194
public function delete()
    {
        $this->defaultTable();
        $this->eq($this->primary, $this->__get($this->primary));

        return DB::delete($this->sql);
    }
24434
public function delete()
    {
        // Validate form
        $form = $this->getForm('Delete' . $this->getEntityName());
        if (!$form->isValid()) {
            $this->addMessage($form->getMessages(), FlashMessenger::NAMESPACE_ERROR);
            return false;
        }

        // Remove account entity
        $entity = $form->getData();
        $this->getEntityManager()->remove($entity);

        // Trigger ondelete
        $this->onDelete($entity);

        // Save
        return $this->save($this->getEntityName() . ' deleted.', 'Unable to delete ' . strtolower($this->getEntityName()) . '.');
    }
232292
public function delete(Entity $entity)
    {
        $this->delete = new Delete('history');
        $this->delete->where(array(
             'history.history_id = ?' => $entity->getHistoryId()
        ));
                 
        return $this->deleteRow();
    }