public function deleteAction($id)
    {
        $delete = function($id) {
            try {
                $this->getMediaManager()->delete($id, true);
            } catch (MediaNotFoundException $e) {
                $entityName = $this->getParameter('sulu.model.media.class');

                throw new EntityNotFoundException($entityName, $id); // will throw 404 Entity not found
            } catch (MediaException $e) {
                throw new RestException($e->getMessage(), $e->getCode()); // will throw 400 Bad Request
            }
        };

        $view = $this->responseDelete($id, $delete);

        return $this->handleView($view);
    }