Delete action for deleting an entity

@return \Zend\Http\Response|\Zend\View\Model\ViewModel
192253
public function deleteAction()
    {
        $id = (int) $this->params()->fromRoute('id', null);

        $request = $this->getRequest();

        if ($request->isPost()) {
            $confirmed = $request->getPost('confirmed', false);
            if ($confirmed) {
                $id = (int) $request->getPost('id');

                $this->getService()->delete($id);

                return $this->redirect()->toRoute($this->getRouteIdentifierPrefix());
            }
        }

        return new ViewModel(array(
            'options'  => $this->getOptions(),
        ));
    }
860204
public function deleteAction()
    {
        $contact = (new \Cms\Orm\CmsContactQuery)->findPk($this->id);
        if ($contact && $contact->delete()) {
            $this->getMessenger()->addMessage('messenger.contact.message.deleted', true);
        }
        $this->getResponse()->redirect('cmsAdmin', 'contact');
    }
873219
public function destroy()
	{
		$mapper = $this->getMapper();
		$admin  = $mapper->getAdmin();

		$model = $this->getModel();
		$model = $model::find($this->getIdentifier());

		// Model before delete hook
		if (method_exists($admin, 'beforeDelete')) {
			$admin->beforeDelete($model);
		}

		// Model delete hook
		if (method_exists($admin, 'deleting')) {
			$admin->deleting($model);
		} else {
			$model->delete();
		}

		// Model after delete hook
		if (method_exists($admin, 'afterDelete')) {
			$result = $admin->afterDelete($model);

			if ($result instanceof \Illuminate\Http\RedirectResponse) {
				$result->send();
			}
		}

		return $this;
	}
1104836
public function delete()
    {
        $args = func_get_args();

        return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_DELETE);
    }
954363
public function delete()
    {
        $table = $this->table;
        $pk = $this->_data[$table->getPrimaryKey()];

        $query = "DELETE FROM {$table->getTableName()} WHERE ";
        $query .= "{$table->getPrimaryKey()} = $pk";

        return $this->_delete($query);
    }
84487
public function actionDeleteImage(): Response
    {
        $model = $this->findModel($this->attachmentModelClass, Yii::$app->request->post('id'));

        $model->delete();

        return $this->asJson([
            'status' => 'success',
        ]);
    }
644261
public function delete()
    {
        if (true === $this->getState()->is('new')) {
            throw new \RuntimeException('You cannot delete a new model');
        }
        if (true === $this->getState()->is('deleted')) {
            return $this;
        }
        $this->getState()->setDeleting();
        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;
    }
1235548
public function trashAction()
    {
        /** @var \Doctrine\ORM\EntityManager $em */
        $em = $this->get('doctrine.orm.entity_manager');

        return $this->render('CMSBundle:AdminStructure:trash.html.twig', [
            'deleted_folders' => $em->getRepository(Folder::class)->findDeleted(),
            'deleted_nodes'   => $em->getRepository(Node::class)->findDeleted(),
        ]);
    }
1234390
public function delete() : Model
	{
		$builder = $this->queryBuilder();

		if (isset($this->softProperties[$this->key])) {
			$builder->where(
				$this->key, $this->softProperties[$this->key]
			);
		}

		$builder->delete($this->getAssociatedTable());

		return $this;
	}
1177325
public function deleteAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth(AdminResources::MODULE, Team::getModuleCode(),
                AccessManager::DELETE)
        ) {
            return $response;
        }

        $con = Propel::getConnection();
        $con->beginTransaction();
        try {
            // Check token
            $this->getTokenProvider()->checkToken(
                $this->getRequest()->query->get("_token")
            );

            $this->getService()->deleteFromId($this->getRequest()->request->get(static::CONTROLLER_ENTITY_NAME . "_id"));
            $con->commit();
            if ($response == null) {
                return $this->redirectToListTemplate();
            } else {
                return $response;
            }
        } catch (\Exception $e) {
            $con->rollBack();

            return $this->renderAfterDeleteError($e);
        }
    }
502814
public function actionDeleteIn()
    {
        $selected = Yii::$app->request->post('selected' , []);

        $ret = \yongtiger\admin\models\Log::deleteAll(['id' => explode(',', $selected)]);
        $str = $ret > 0 ? ' (IDs [' . $selected . '])' : '';
        Yii::$app->session->setFlash('info', Module::t('message', 'Deleted {0} logs.', $ret) . $str);

        return $this->redirect(['index']);
    }
118927
public function deleteAction($id)
    {
        $documentManager = $this->getDocumentManager();
        $document = $documentManager->find($id);
        $documentManager->remove($document);
        $documentManager->flush();

        return $this->handleView($this->view(null));
    }
1222087
public function delete()
    {
        $column  = Input::get('params.column');
        $session = app('request')->session();
        $key     = uri();
        $params  = $session->get($key);
        $data    = [];
        foreach ($params as $name => $values) {
            if (isset($values['column']) && $values['column'] == $column) {
                continue;
            }
            $data[$name] = $values;
        }
        $session->put($key, $data);
        $session->save();
        return response('', 200);
    }
492340
public function deleteAction()
	{
		$repository = $this->container->getDoctrine()->getManager()->getRepository(FileAbstraction::CN());
		/* @var $repository FileNestedSetRepository */
		$repository->getNestedSetRepository()->lock();

		$file = $this->getEntity();

		$this->checkActionPermission($file, FileAbstraction::PERMISSION_DELETE_NAME);

		if (is_null($file)) {
			throw new CmsException(null, 'File doesn\'t exist anymore');
		}

		// try to delete
		try {
			if ($file->hasChildren()) {
				$confirmation = $this->getConfirmation('Are You sure?');

				if ($confirmation instanceof Response) {
					return $confirmation;
				}

				$this->removeFilesRecursively($file);
			} else {
				$this->removeSingleFile($file);
			}
		} catch (NotEmptyException $e) {
			// Should not happen
			throw new CmsException(null, "Cannot delete not empty folders");
		}

		return new SupraJsonResponse(null);
	}
800440
public function deleteAction(Request $request, $id)
    {
        $language = $this->getLanguage($request);
        $webspace = $this->getWebspace($request);
        $force = $this->getBooleanRequestParameter($request, 'force', false, false);

        if (!$force) {
            $references = array_filter(
                $this->getRepository()->getReferences($id),
                function(PropertyInterface $reference) {
                    return $reference->getParent()->isNodeType('sulu:page');
                }
            );

            if (count($references) > 0) {
                $data = [
                    'structures' => [],
                    'other' => [],
                ];

                foreach ($references as $reference) {
                    $content = $this->get('sulu.content.mapper')->load(
                        $reference->getParent()->getIdentifier(),
                        $webspace,
                        $language,
                        true
                    );
                    $data['structures'][] = $content->toArray();
                }

                return $this->handleView($this->view($data, 409));
            }
        }

        $view = $this->responseDelete(
            $id,
            function($id) use ($webspace) {
                try {
                    $this->getRepository()->deleteNode($id, $webspace);
                } catch (DocumentNotFoundException $ex) {
                    throw new EntityNotFoundException('Content', $id);
                }
            }
        );

        return $this->handleView($view);
    }
934115
protected function performDeleteOnModel()
    {
        if ($this->forceDeleting) {
            $this->exists = false;

            return $this->setKeysForSaveQuery($this->newModelQuery())->forceDelete();
        }

        return $this->runSoftDelete();
    }