Delete a folder.

@param Request $request

@return \Illuminate\Http\JsonResponse
502005
public function deleteFolder(Request $request)
    {
        $folder = $request->get('path');

        try {
            $result = $this->mediaManager->deleteDirectory($folder);
            if ($result !== true) {
                $error = $this->mediaManager->errors() ?: trans('media-manager::messages.delete_error', ['entity' => 'folder']);

                return $this->errorResponse($error);
            }

            return ['success' => trans('media-manager::messages.delete_success', ['entity' => 'folder'])];
        } catch (\Exception $e) {
            return $this->errorResponse($e->getMessage());
        }
    }
1216354
public function delete(Request $request)
    {
        $json = [];

        if ($request->get('directory')) {
            $this->storage->deleteDirectory($request->get('directory'));
            Image::deleteDirectory($this->path . $request->get('directory'));
            $json['success'] = trans('admin::image.success.delete');
        } elseif ($request->get('file')) {
            $this->storage->delete($request->get('file'));
            Image::delete($this->path . $request->get('file'));
            $json['success'] = trans('admin::image.success.delete');
        } else {
            $json['error'] = trans('admin::image.error.delete');
        }

        return response()
            ->json($json);
    }
1258403
public function deleteAction(Request $request, $id)
    {
        $manager = $this->get('opifer.content.content_manager');
        $content = $manager->getRepository()->find($id);

        $em = $this->get('doctrine')->getManager();
        $em->remove($content);
        $em->flush();

        return new JsonResponse(['success' => true]);
    }
388122
public function deleteAction(Request $request)
    {
        $gridSource = $this->get('dtc_grid.manager.source')->get($request->get('id'));
        $id = $request->get('identifier');
        $gridSource->remove($id);
        $response = new Response();
        $response->setStatusCode(204);

        return $response;
    }
458382
protected function deleteDirectory(Request $request)
    {
        try {
            $dir = $request->input('s');
            Storage::deleteDirectory($dir);

            return $this->notifySuccess($dir . ' successfully deleted!');
        } catch (\ErrorException $e) {
            return $this->notifyError($e->getMessage());
        }
    }
1048340
public function deleteAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $folder = $this->findFolderById($request->attributes->get('id'));

        $result = array();
        try {
            $this->removeFolder($folder);
        } catch (DBALException $e) {
            $result = array(
                'error'   => true,
                'message' => 'Ce dossier n\'est pas vide.',
            );
        }

        $response = new Response(json_encode($result, JSON_FORCE_OBJECT));
        $response->headers->add(array('Content-Type' => 'application/json'));
        return $response;
    }
297258
public function delete(Request $request)
    {
        $category = $this->category->find($request->get('category'));

        if (!$category) {
            return Response::json(['errors' => true]);
        }

        $this->category->destroy($category);

        return Response::json(['errors' => false]);
    }
246073
public function putDestroy(Request $request)
    {
        $validation = \Validator::make($request->all(), [
            'id' => 'required'
        ]);
        if ($validation->fails()) {
            return redirect()->back()->withErrors($validation)->withInput($request->all());
        }

        $data = $this->model->where($this->model->getKeyName(), $request->get('id'))->get()->last();
        $data->delete();

        return redirect()->to(action('\\'.get_class($this).'@getIndex'));
    }
1068499
public function createAction(Request $request)
    {
        $parentId = $request->get('parent_id');
        $name = $request->get('folder_name');

        $volume = $this->get('phlexible_media_manager.volume_manager')->getByFolderId($parentId);
        $parentFolder = $volume->findFolder($parentId);

        try {
            $folder = $volume->createFolder($parentFolder, $name, array(), $this->getUser()->getId());

            return new ResultResponse(true, 'Folder created.', [
                'folder_id' => $folder->getId(),
                'folder_name' => $folder->getName(),
            ]);
        } catch (AlreadyExistsException $e) {
            return new ResultResponse(false, $e->getMessage(), [
                'folder_name' => 'Folder already exists.',
            ]);
        } catch (\Exception $e) {
            return new ResultResponse(false, $e->getMessage());
        }
    }
203991
public function deleteAction(Request $request)
    {
        $fileId = $request->get('file_id');
        $fileIds = explode(',', $fileId);

        $volumeManager = $this->get('phlexible_media_manager.volume_manager');

        foreach ($fileIds as $fileId) {
            try {
                $volume = $volumeManager->getByFileId($fileId);
                $file = $volume->findFile($fileId);
                $volume->deleteFile($file, $this->getUser()->getId());
            } catch (NotFoundException $e) {
            }
        }

        return new ResultResponse(true, count($fileIds).' file(s) deleted.');
    }
1289551
public function deleteItemCondition(Request $request)
    {
        $this->validate(
            $request,
            [
                'item_condition_id' => 'required|integer|exists:item_conditions',
            ]
        );

        $item_condition = ItemCondition::find($request->input('item_condition_id'));

        if ($item_condition->items()->count()) {
            return redirect()->back()->withErrors(['item_condition_id' => trans('mustard::admin.item_condition_has_items')]);
        }

        $item_condition->delete();

        return redirect()->back()->withStatus(trans('mustard::admin.item_condition_deleted'));
    }
286289
public function update(Request $request, string $folder = '')
    {
        if (empty($request->name)) {
            return $this->json('Name property is required.', 422);
        }

        $this->manager->resetPath($folder);

        if (!$this->manager->blobExists()) {
            return $this->json('Folder not found.', 404);
        }

        $details = $this->manager->rename($request->name);

        return $this->json($details);
    }
1053020
public function renameAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $folder = $this->findFolderById($request->attributes->get('id'));

        $folder->setName($request->request->get('name'));

        if (true !== $message = $this->validateFolder($folder)) {
            $result = array(
                'error'   => true,
                'message' => $message,
            );
        } else {
            $this->persistFolder($folder);
            $result = array(
                'name' => $folder->getName(),
            );
        }

        $response = new Response(json_encode($result, JSON_FORCE_OBJECT));
        $response->headers->add(array('Content-Type' => 'application/json'));
        return $response;
    }
1019620
public function removeFromOrderAction(Request $request)
    {
        $updater = $this->container->get('librinfo_ecommerce.order.item_updater');

        $result = $updater->updateItemCount($request->get('order'), $request->get('item'), false);

        if ($result['lastItem'] != null) {
            $result['message'] = $this->container->get('translator')->trans('There must be at least one item left in the order');
        }

        return new JsonResponse($result);
    }
717270
public function renameFolder(Request $request)
    {
        $namespace = $request->request->get('namespace');
        $parent = $request->request->get('parent');
        $oldName = $request->request->get('oldname');
        $newName = $request->request->get('newname');

        try {
            $dir = $this->filesystem()->getDir("$namespace://$parent/$oldName");
            if (!$dir) {
                return $this->json(
                    sprintf("Only directories are allowed to be renamed with this method"),
                    Response::HTTP_BAD_REQUEST
                );
            }
            $this->filesystem()->rename("$namespace://$parent/$oldName", "$parent/$newName");

            return $this->json($newName, Response::HTTP_OK);
        } catch (ExceptionInterface $e) {
            $msg = Trans::__('Unable to rename directory: %DIR%', ['%DIR%' => $oldName]);
            $this->logException($msg, $e);

            if ($e instanceof FileExistsException) {
                $status = Response::HTTP_CONFLICT;
            } elseif ($e instanceof FileNotFoundException) {
                $status = Response::HTTP_NOT_FOUND;
            } else {
                $status = Response::HTTP_INTERNAL_SERVER_ERROR;
            }

            return $this->json($msg, $status);
        }
    }
334264
public function send(Request $request)
    {
        $response      = new DeleteIndexResponse();
        $rpbDeleteReq  = $this->createRpbMessage($request);

        $this->client->send($rpbDeleteReq, RiakMessageCodes::YOKOZUNA_INDEX_DELETE_REQ, RiakMessageCodes::DEL_RESP);

        return $response;
    }
1343605
public function moveAction(Request $request)
    {
        $folderId = $request->get('folderID');
        $fileIds = json_decode($request->get('fileIDs'));

        $volume = $this->getVolumeByFolderId($folderId);
        $folder = $volume->findFolder($folderId);

        $skippedFiles = [];

        foreach ($fileIds as $fileId) {
            $file = $volume->findFile($fileId);
            try {
                $volume->moveFile($file, $folder, $this->getUser()->getId());
            } catch (AlreadyExistsException $e) {
                $skippedFiles[] = $file->getName();
            }
        }

        return new ResultResponse(true, 'File(s) moved.', $skippedFiles);
    }