Remove thumbnail for given path

@param Request $request
@return JsonResponse

@Route("/clear-thumbnail")
775977
public function clearThumbnailAction(Request $request)
    {
        $path = $request->get('path');
        $filter = $request->get('filter');
        $response = [
            'error' => false,
            'success' => false
        ];

        if ($path && $filter) {
            /** @var CacheManager $cacheManager */
            $cacheManager = $this->get('liip_imagine.cache.manager');
            // Filter is purposely left out on the remove call, it should remove all the caches for the current given file.
            $cacheManager->remove($path);
            $cacheManager->getBrowserPath($path, $filter);
            $response['success'] = true;
            $response['url']  = $cacheManager->generateUrl($path, $filter);
        } else {
            $response['error'] = 'No "path" or "filter" provided';
        }

        return new JsonResponse($response);
    }
1290431
public function deleteAjaxAction( Request $request ) {
		$id          = $request->get( 'id' );
		$pageId      = $request->get( 'pageId' );
		$uniqId      = $request->get( 'uniqId' );
		$code        = $request->get( 'code' );
		$formFieldId = $request->get( 'formFieldId' );

		if ( $id ) {
			$layoutBlock = $this->admin->getObject( $id );
			if ( $layoutBlock ) {
				$this->admin->delete( $layoutBlock );
			}
		}
		$html = $this->getLayoutBlockFormWidget( $pageId, $formFieldId, $uniqId, $code );

		return new JsonResponse( [
			'messageStatus' => 'success',
			'message'       => $this->translate( 'message.layout_block_deleted' ),
			'html'          => $html,
		] );
	}
579046
public function removeAction(Request $request)
    {
        $block = $this->findBlockByRequest($request);
        $row = $block->getRow();

        try {
            $this->getEditor()->getBlockManager()->delete($block);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        // Stores id for front removal
        $removedId = $this->getViewBuilder()->buildBlock($block)->getAttributes()->getId();

        $this->validate($row);
        $this->persist($row);

        $data = [
            'removed' => [$removedId],
            //'rows'    => [$this->getViewBuilder()->buildRow($row)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
368507
public function deleteAction(Request $request)
    {
        $siterootId = $request->get('id');

        $siterootManager = $this->get('phlexible_siteroot.siteroot_manager');

        $siteroot = $siterootManager->find($siterootId);
        $siterootManager->deleteSiteroot($siteroot);

        return new ResultResponse(true, 'Siteroot deleted.');
    }
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());
        }
    }
1352502
public function destroy(Request $request)
    {
        $count = 0;

        // Carregar IDs
        $ids = $this->getId($request);
        $ids = explode(',', $ids);
        foreach ($ids as $id) {
            $count += $this->deleteModel($id) ? 1 : 0;
        }

        return response()->json((object)['success' => ($count > 0), 'count' => $count]);
    }
1141093
public function destroy(Request $request, $id)
    {
        $slug = $this->getSlug($request);

        $dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();

        // Check permission
        Voyager::canOrFail('delete_'.$dataType->name);

        $data = call_user_func([$dataType->model_name, 'findOrFail'], $id);

        foreach ($dataType->deleteRows as $row) {
            if ($row->type == 'image') {
                $this->deleteFileIfExists('/uploads/'.$data->{$row->field});

                $options = json_decode($row->details);

                if (isset($options->thumbnails)) {
                    foreach ($options->thumbnails as $thumbnail) {
                        $ext = explode('.', $data->{$row->field});
                        $extension = '.'.$ext[count($ext) - 1];

                        $path = str_replace($extension, '', $data->{$row->field});

                        $thumb_name = $thumbnail->name;

                        $this->deleteFileIfExists('/uploads/'.$path.'-'.$thumb_name.$extension);
                    }
                }
            }
        }

        $data = $data->destroy($id)
            ? [
                'message'    => "Successfully Deleted {$dataType->display_name_singular}",
                'alert-type' => 'success',
            ]
            : [
                'message'    => "Sorry it appears there was a problem deleting this {$dataType->display_name_singular}",
                'alert-type' => 'error',
            ];

        return redirect()->route("voyager.{$dataType->slug}.index")->with($data);
    }
225396
public function removeitemAction(Request $request, $id) {
        $em = $this->getDoctrine()->getManager();

        $galleryItem = $em->getRepository('AmulenMediaBundle:GalleryItem')->find($id);

        $gallery = $galleryItem->getGallery();

        $em->remove($galleryItem);
        $em->flush();

        return $this->redirect($this->generateUrl('admin_gallery_items', array("id" => $gallery->getId())));
    }
1283509
public function store(Request $request)
    {
        $this->manager->resetPath($request->folder);

        if (empty($request->name)) {
            return $this->json('Name property is required.', 422);
        }

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

        $result = $this->manager->makeDirectory($request->name)->fullDetails();

        return $this->json($result);
    }
442552
public function deleteAction(Request $request)
    {
        try {
            $manager = $this->get('ongr_settings.settings_manager');
            $manager->delete($request->get('name'));

            return new JsonResponse(['error' => false]);
        } catch (\Exception $e) {
            return new JsonResponse(
                [
                    'error' => true,
                    'message' => 'Error occurred please try to delete setting again.'
                ]
            );
        }
    }
52956
public function localPathFoldersAction(Request $request)
    {
        $form = $this->createForm(new ChoiceLocalPath());
        $form->handleRequest($request);
        $path = $form->get('path')->getData() ?: Filesystem::getUserHomeDir();

        if (($root = $request->get('root')) && strpos($path, $root) !== 0) {
            $path = $root;
        }

        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()
            ->getResponse([(new \DateTime())->setTimestamp(filemtime($path))], -1, new JsonResponse());
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        return $response->setData([
            'path' => $path,
            'folders' => Filesystem::scandir($path, Filesystem::DIRECTORY),
        ]);
    }
1374647
protected function deleteThumbnail($path)
	{
		if(file_exists($path)) {
			if(is_dir($path)) {
				if($this->config['s3']['localThumbsPath']) {
					$this->unlinkRecursive($path);
				} else {
					$key = $this->getDynamicPath($path, false);
					$this->s3->batchDelete($key);
				}
			} else {
				unlink($path);
			}
		}
	}
248039
public function templatesByLangDeleteBulkAction(Request $request)
    {
        $query = $request->query->all();
        $options = $this->options['deleteBulk'];

        if (isset($query['options'])) {
            $options = $query['options'];
        }
        $templateRepo = $this->om->getRepository(Template::class);
        $toDelete = [];
        $templates = $this->decodeIdsString($request, Template::class);

        foreach ($templates as $template) {
            $localizedTemplates = $templateRepo->findBy([
                'name' => $template->getName(),
                'type' => $template->getType(),
            ]);
            foreach ($localizedTemplates as $localizedTemplate) {
                $toDelete[] = $localizedTemplate;
            }
        }
        $this->crud->deleteBulk($toDelete, $options);

        return new JsonResponse(null, 204);
    }
37292
public function remove(Request $request)
    {
        $type = $request->get('type');

        return $this->manager()->{$type}()->remove($request->all());
    }
952498
public function updateImage(Request $request)
    {
        $fileName = $request->query->get('file');
        $type = $request->query->get('type');
        $value = $request->query->get('value');
      
        /** @var Image $entity */
        $qb = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')
                ->createQueryBuilder('i');
        $image = $qb->where($qb->expr()->like('i.path', ':path'))
            ->setParameter('path','%'.$fileName.'%')
            ->getQuery()
            ->getOneOrNullResult();

//        $image = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')->findOneBy(array('path' => $fileName));
       
        if (!$image) {
            throw new NotFoundHttpException('Unable to find Image entity.');
        }
        

        if($type == 'title') $image->setTitle($value);
        if($type == 'alt') $image->setAlt($value);
        
        $this->getDoctrine()->getManager()->flush();
            

        return new JsonResponse(array('success' => true));
    }
159483
public function deleteAction(Request $request, $key)
    {
        $webspaceKey = $this->getRequestParameter($request, 'webspace', true);
        $this->get('sulu_security.security_checker')->checkPermission(
            new SecurityCondition(SnippetAdmin::getDefaultSnippetsSecurityContext($webspaceKey)),
            PermissionTypes::EDIT
        );

        $areas = $this->getLocalizedAreas();
        $area = $areas[$key];

        $this->get('sulu_snippet.default_snippet.manager')->remove($webspaceKey, $key);

        return new JsonResponse(
            [
                'key' => $key,
                'template' => $area['template'],
                'title' => $area['title'],
                'defaultUuid' => null,
                'defaultTitle' => null,
                'valid' => true,
            ]
        );
    }
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]);
    }