Delete media.

@param  mixed $id
@return Response
@throws BadRequestHttpException
548007
public function deleteAction($id)
    {
        if (null === $media = $this->getMediaRepository()->find($id)) {
            throw new NotFoundHttpException(sprintf('Cannot find media with id `%s`.', $id));
        }

        $em = $this->getEntityManager();

        try {
            $em->getRepository('BackBee\ClassContent\AbstractClassContent')->deleteContent($media->getContent(), true);
            $em->remove($media);
            $em->flush();
        } catch (\Exception $e) {
            throw new BadRequestHttpException(sprintf('Error while deleting media `%s`: %s', $id, $e->getMessage()));
        }

        return $this->createJsonResponse(null, 204);
    }
1356037
public function deleteAction(Request $request, $id)
    {
        try {
            $mediaManager = $this->get('opifer.media.media_manager');
            $media = $mediaManager->getRepository()->find($id);

            $dispatcher = $this->get('event_dispatcher');
            $event = new MediaResponseEvent($media, $request);
            $dispatcher->dispatch(OpiferMediaEvents::MEDIA_CONTROLLER_DELETE, $event);

            if (null !== $event->getResponse()) {
                return $event->getResponse();
            }

            $mediaManager->remove($media);
        } catch (\Exception $e) {
            return new JsonResponse(['success' => false, 'message' => $e->getMessage()]);
        }

        return new JsonResponse(['success' => true]);
    }
1320093
public function destroy($id)
    {
        try {
            $wasSuccessful = $this->repository->delete($id);
            return Response::apiResponse([
                'data' => $wasSuccessful
            ]);
        } catch (\Exception $e) {
            return Response::apiResponse([
                'httpCode' => 400,
                'message' => $e->getMessage()
            ]);
        }
    }
302652
public function destroy($id, Request $request)
    {
        $model = $this->model();

        $force = false;
        if (method_exists($model, 'forceDelete')) {
            $this->validate($request, ['force' => ['boolean']]);

            $model = $model->withTrashed();
            $force = (bool) $request->input('force');
        }

        return $this->deleteModel($model->find($id), 'delete', $force);
    }
597153
public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);

        $album = $this->PhotosAlbums->get($id);

        //Before deleting, it checks if the album has some photos
        if (!$album->photo_count) {
            $this->PhotosAlbums->deleteOrFail($album);
            $this->Flash->success(I18N_OPERATION_OK);
        } else {
            $this->Flash->alert(I18N_BEFORE_DELETE);
        }

        return $this->redirect(['action' => 'index']);
    }
381506
public function actionDeleteVideo($id)
    {
        $model = $this->module->manager->findVideoGalleryItemById($id);
        if ($model === null) {
            throw new NotFoundHttpException('The requested page does not exist');
        }

        $model->delete();

        \Yii::$app->getSession()->setFlash('video_gallery.success', \Yii::t('video_gallery', 'Video has been deleted'));

        return $this->redirect(['videos', 'id' => $model->video_gallery_id]);
    }
799304
public function destroyUpdate($id)
    {
        return $this->send($this->getHttp()->post($this->url.'updates/'.$id.'/destroy.json'));
    }
388590
public function delete($id = null) {
		$block = $this->Blocks->get($id);
		$this->request->allowMethod('post', 'delete');
		if ($this->Blocks->delete($block)) {
			$this->Flash->success('The block has been deleted.');
		} else {
			$this->Flash->error('The block could not be deleted. Please, try again.');
		}
		return $this->redirect(['action' => 'index']);
	}
1230929
public function deleteAction($id)
    {
        $delete = function ($id) {
            $this->getManager()->delete($id);
        };
        $view = $this->responseDelete($id, $delete);

        return $this->handleView($view);
    }
850630
public function destroy($id)
    {
        try {
            if (($ret = $this->callDeleting()) instanceof Response) {
                return $ret;
            }

            collect(explode(',', $id))->filter()->each(function ($id) {
                $builder = $this->model()->newQuery();

                if ($this->isSoftDeletes) {
                    $builder = $builder->withTrashed();
                }

                $model = $builder->with($this->getRelations())->findOrFail($id);

                if ($this->isSoftDeletes && $model->trashed()) {
                    $this->deleteFiles($model, true);
                    $model->forceDelete();

                    return;
                }

                $this->deleteFiles($model);
                $model->delete();
            });

            if (($ret = $this->callDeleted()) instanceof Response) {
                return $ret;
            }

            $response = [
                'status'  => true,
                'message' => trans('admin.delete_succeeded'),
            ];
        } catch (\Exception $exception) {
            $response = [
                'status'  => false,
                'message' => $exception->getMessage() ?: trans('admin.delete_failed'),
            ];
        }

        return response()->json($response);
    }
96040
public function actionDelete($id)
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $routes = $this->module->routes;

        $model = Mediafile::findOne($id);

        if ($model->isImage()) {
            $model->deleteThumbs($routes);
        }

        $model->deleteFile($routes);
        $model->delete();

        return ['success' => 'true'];
    }
943581
public function delete(string $id)
    {
        $url = $this->url.'/'.$id;

        return $this->curl->delete($url);
    }
808467
public function destroy($id)
    {
        try {
            $this->contentTypes->destroy($id);
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.delete', ['object' => trans('soda::terminology.content_type')]));
        }

        return redirect()->route('soda.content-types.index')->with('warning', trans('soda::messages.deleted', ['object' => trans('soda::terminology.content_type')]));
    }
646888
public function delete(int $id): MediaEndpointInterface
    {
        $this->shopware()->delete('/api/media/'.(string)$id);

        return $this;
    }
203441
public function actionDelete($id)
    {
        $this->findModel($id)->delete();
        Helper::invalidate();

        return $this->redirect(['index']);
    }
1216058
public function delete($id)
    {
        $response = $this->restClient->delete($this->endpoint . '/' . $id);

        return $response['body'];
    }
579124
public function deleteAction($id)
    {
        $id = $this->getRequest()->get($this->admin->getIdParameter());
        $object = $this->admin->getObject($id);

        if (!$object) {
            throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
        }

        if (false === $this->admin->isGranted('DELETE', $object)) {
            throw new AccessDeniedException();
        }
        /** @var Request $request */
        $request = $this->get('request_stack')->getCurrentRequest();
        if ($request->getMethod() == 'DELETE') {
            try {
                $this->admin->delete($object);
                $this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_delete_success');
            } catch (ModelManagerException $e) {
                $this->get('session')->getFlashBag()->add('sonata_flash_error', 'flash_delete_error');
            }

            return new RedirectResponse($this->admin->generateUrl(
                'list',
                ['active_tab' => $this->getRequest()->get('context')]
            ));
        }

        return $this->render(
            $this->admin->getTemplate('delete'),
            [
                'object' => $object,
                'action' => 'delete',
            ]
        );
    }