Handles removing sections based on submitted form.

@param \Symfony\Component\HttpFoundation\Request $request

@return \Symfony\Component\HttpFoundation\Response
12585
public function bulkDeleteAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('section', 'edit'));
        $form = $this->formFactory->deleteSections(
            new SectionsDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (SectionsDeleteData $data) {
                foreach ($data->getSections() as $sectionId => $selected) {
                    $section = $this->sectionService->loadSection($sectionId);
                    $this->sectionService->deleteSection($section);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Section '%name%' removed.") */
                            'section.delete.success',
                            ['%name%' => $section->name],
                            'section'
                        )
                    );
                }
            });

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

        return $this->redirect($this->generateUrl('ezplatform.section.list'));
    }
635325
public function postEdit(Request $request)
    {

        $form = FormBuilder::create(get_class($this->form), [
            'model' => $this->model
        ]);

        if ($form->hasError())
        {
            return $form->validateAndRedirectBack();
        }

        $permissions = $request->get('permission');
        $this->model->truncate();


        foreach ($permissions as $role_id=>$permission) {

            foreach ($permission as $service_id) {
                $permModel = new $this->model;
                $permModel->role_id = $role_id;
                $permModel->service_id = $service_id;
                $permModel->save();
            }
        }


        return redirect()->to(action('\\'.get_class($this).'@getIndex'));

    }
144952
public function updateAction(Request $request): Response
    {
        $form = $this->formFactory->updateLocation();
        $form->handleRequest($request);

        $location = $form->getData()->getLocation();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (LocationUpdateData $data) {
                $location = $data->getLocation();

                $locationUpdateStruct = new LocationUpdateStruct(['sortField' => $data->getSortField(), 'sortOrder' => $data->getSortOrder()]);
                $this->locationService->updateLocation($location, $locationUpdateStruct);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Location '%name%' updated.") */
                        'location.update.success',
                        ['%name%' => $location->getContentInfo()->name],
                        'location'
                    )
                );

                return new RedirectResponse($this->generateUrl('_ezpublishLocation', [
                        'locationId' => $location->getContentInfo()->mainLocationId,
                        '_fragment' => DetailsTab::URI_FRAGMENT,
                    ]));
            });

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

        return $this->redirect($this->generateUrl('_ezpublishLocation', [
            'locationId' => $location->getContentInfo()->mainLocationId,
            '_fragment' => DetailsTab::URI_FRAGMENT,
        ]));
    }
1187921
public function removeAction(Request $request): Response
    {
        $form = $this->formFactory->removeCustomUrl();
        $form->handleRequest($request);

        $location = $form->getData()->getLocation();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (CustomUrlRemoveData $data) {
                $aliasToRemoveList = [];
                foreach ($data->getUrlAliases() as $customUrlId => $selected) {
                    $aliasToRemoveList[] = $this->urlAliasService->load($customUrlId);
                }
                $this->urlAliasService->removeAliases($aliasToRemoveList);

                return $this->redirectToLocation($data->getLocation(), UrlsTab::URI_FRAGMENT);
            });

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

        if ($location) {
            return $this->redirectToLocation($location, UrlsTab::URI_FRAGMENT);
        }

        return $this->redirectToRoute('ezplatform.dashboard');
    }
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.');
    }
687888
public function delete(Request $request, $page)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin', 'editor']);

        $page = Page::withTrashed()->findOrFail($page);
        return view('page::pages.delete', ['page' => $page]);
    }
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.'
                ]
            );
        }
    }
320816
protected function processPost(Request $request)
    {
        $resource = $this->getResourceManager()->createNewInstance();
        return $this->processAction($request, 'POST', $resource);
    }
1058787
public function removeAction(Request $request): Response
    {
        $form = $this->formFactory->removeBookmark(
            new BookmarkRemoveData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (BookmarkRemoveData $data) {
                foreach ($data->getBookmarks() as $locationId => $selected) {
                    $this->bookmarkService->deleteBookmark(
                        $this->locationService->loadLocation($locationId)
                    );
                }

                return $this->redirectToRoute('ezplatform.bookmark.list');
            });

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

        return $this->redirectToRoute('ezplatform.bookmark.list');
    }
479054
public function destroy(Request $request, $page)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin', 'editor']);

        $page = Page::withTrashed()->findOrFail($page);

        if ($page->trashed() && !$request->input('confirm_delete')) {
            return redirect()->route('admin.pages.page.delete', $page);
        }

        if ($request->input('confirm_delete')) {
            $page->forceDelete();
            return redirect()->route('admin.pages.index.trashed');
        }

        $page->status = 1;
        $page->save();
        $page->delete();

        flash('Page has been moved to trash')->success();

        return back();
    }
1307404
public function restoreAction(Request $request): Response
    {
        if (!$this->isGranted(new Attribute('content', 'restore'))) {
            return $this->redirect($this->generateUrl('ezplatform.trash.list'));
        }

        $form = $this->formFactory->restoreTrashItem();
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (TrashItemRestoreData $data) {
                $newParentLocation = $data->getLocation();

                foreach ($data->getTrashItems() as $trashItem) {
                    $this->trashService->recover($trashItem, $newParentLocation);
                }

                if (null === $newParentLocation) {
                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Items restored under their original location.") */
                            'trash.restore_original_location.success',
                            [],
                            'trash'
                        )
                    );
                } else {
                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Items restored under '%location%' location.") */
                            'trash.restore_new_location.success',
                            ['%location%' => $newParentLocation->getContentInfo()->name],
                            'trash'
                        )
                    );
                }

                return new RedirectResponse($this->generateUrl('ezplatform.trash.list'));
            });

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

        return $this->redirect($this->generateUrl('ezplatform.trash.list'));
    }
276609
public function moveDownAction(Request $request)
    {
        $container = $this->findContainerByRequest($request);

        try {
            $sibling = $this->getEditor()->getContainerManager()->moveDown($container);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $content = $container->getContent();

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

        $data = [
            'containers' => [
                $this->getViewBuilder()->buildContainer($container),
                $this->getViewBuilder()->buildContainer($sibling),
            ],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
650803
public function bulkDeleteAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'delete'));
        $form = $this->formFactory->deleteRoles(
            new RolesDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RolesDeleteData $data) {
                foreach ($data->getRoles() as $roleId => $selected) {
                    $role = $this->roleService->loadRole($roleId);
                    $this->roleService->deleteRole($role);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Role '%role%' removed.") */
                            'role.delete.success',
                            ['%role%' => $role->identifier],
                            'role'
                        )
                    );
                }

                return new RedirectResponse($this->generateUrl('ezplatform.role.list'));
            });

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

        return new RedirectResponse($this->generateUrl('ezplatform.role.list'));
    }
395662
public function edit(Request $request)
    {
        $post = $this->api('post.fetch', $request->route('post'))->get();

        event(new UserEditingPost($post));

        if ($post->trashed()) {
            return abort(404);
        }

        $this->authorize('edit', $post);

        $thread = $post->thread;
        $category = $post->thread->category;

        return view('forum::post.edit', compact('category', 'thread', 'post'));
    }
1357823
public function assignSectionAction(Request $request): Response
    {
        $form = $this->createForm(LocationAssignSectionType::class, new LocationAssignSubtreeData());
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (LocationAssignSubtreeData $data) {
                $section = $data->getSection();
                $location = $data->getLocation();

                $this->sectionService->assignSectionToSubtree($location, $section);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Section '%name%' has been assigned to subtree") */
                        'location.assign_section.success',
                        ['%name%' => $section->name],
                        'location'
                    )
                );

                return $this->redirectToLocation($location, DetailsTab::URI_FRAGMENT);
            });

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

        if (($location = $form->getData()->getLocation()) !== null) {
            return $this->redirectToLocation($location, DetailsTab::URI_FRAGMENT);
        }

        return $this->redirectToRoute('ezplatform.dashboard');
    }
754810
public function submitAction(Request $request)
    {
        $template = 'EnhavoSearchBundle:Admin:Search/result.html.twig';

        $term = $request->get('q', '');

        $filter = new Filter();
        $filter->setTerm($term);

        $results = $this->searchEngine->searchPaginated($filter);
        $results = $this->resultConverter->convert($results, $term);

        return $this->render($template, [
            'results' => $results,
            'term' => $term
        ]);
    }
233056
public function moveAction(Request $request)
    {
        $section = $this->getSection($request->query->get('id'), true);

        $terms = $section->getTerms();

        // [OP 2014-09-07] Verify that the target section is part of the same terms!
        $dest = $this->getQuery()
            ->filterByTermsId($terms->getId())
            ->findPk($request->query->get('dest_id'));

        if (!$request->isXmlHttpRequest() || !$dest) {
            throw $this->createNotFoundException('Section not found');
        }

        $data = array();

        try {
            switch ($request->query->get('as')) {
                case 'child':
                    $section->moveToFirstChildOf($dest);
                    break;
                case 'sibling':
                    $dest->isRoot() ?
                        $section->moveToFirstChildOf($dest)
                        : $section->moveToNextSiblingOf($dest);
                    break;
                default:
                    $section->moveToLastChildOf($dest);
                    break;
            }

            $data['success'] = true;
            $this->get('session')->getFlashBag()->add(
                'notice',
                $this->get('translator')->trans('section.move.success', array(), 'CPTermsBundle', $request->getLocale())
            );

        } catch (RuntimeException $e) {
            $data['success'] = false;
            $this->get('session')->getFlashBag()->add(
                'notice',
                $this->get('translator')->trans('section.move.error', array(), 'CPTermsBundle', $request->getLocale())
            );

        }

        return new Response(json_encode($data), 200, array('Content-Type' => 'application/json'));
    }