Change the page viewing mode to live or draft.

@param Request $request
@param $status
@param $path

@return RedirectResponse

@throws AccessDeniedException
171297
protected function changeViewMode(Request $request, $status, $path)
    {
        if (false === $this->get('security.authorization_checker')->isGranted('ROLE_SONATA_ADMIN')) {
            $message = 'Please login to carry out this action';
            throw new AccessDeniedException($message);
        }

        $request->getSession()->set('_viewStatus', $status);

        if ($path) {
            $url = base64_decode($path);
        } else {
            $url = $this->get('router')->generate('networking_init_cms_default');
        }

        return $this->redirect($url);
    }
1008600
public function to($path, $status = 302, $headers = array(), $secure = null)
    {
        $path = $this->generator->to($path, array(), $secure);

        return $this->createRedirect($path, $status, $headers);
    }
401161
public function index(Request $request, $status = null)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin', 'editor']);

        $status = $request->get('status');
        $query = $request->get('query');

        $pages = Page::ofStatus($status)
            ->orderBy('updated_at', 'desc')
            ->orderBy('created_at', 'desc')
            ->with('pagetype')
            ->paginate(self::PAGINATION_ITEMS);

        return view('page::pages.index', [
            'pages' => $pages,
            'status' => $status,
            'query' => $query
        ]);
    }
439596
public function updateVisibilityAction(Request $request): Response
    {
        $form = $this->formFactory->updateVisibilityLocation();
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $data = $form->getData();

            /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */
            $location = $data->getLocation();
            $hidden = $data->getHidden();

            try {
                /** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */
                $contentInfo = $location->getContentInfo();

                if ($hidden) {
                    $this->locationService->hideLocation($location);
                    $message = $this->translator->trans(
                        /** @Desc("Location '%name%' hidden.") */
                        'location.update_success.success.hidden',
                        ['%name%' => $contentInfo->name],
                        'location'
                    );
                } else {
                    $this->locationService->unhideLocation($location);
                    $message = $this->translator->trans(
                        /** @Desc("Location '%name%' unhidden.") */
                        'location.update_success.success.unhidden',
                        ['%name%' => $contentInfo->name],
                        'location'
                    );
                }
            } catch (APIRepositoryUnauthorizedException $e) {
                return new JsonResponse(['errors' => [$e->getMessage()]], Response::HTTP_UNAUTHORIZED);
            }
        } else {
            $errors = [];
            foreach ($form->getErrors(true, true) as $formError) {
                $errors[] = $formError->getMessage();
            }

            return new JsonResponse(['errors' => $errors], Response::HTTP_UNPROCESSABLE_ENTITY);
        }

        return new JsonResponse(['message' => $message]);
    }
1167697
public function entriesStatusChangeAction($status, Request $request)
    {
        $entries = [];
        $serializedEntries = [];
        $entriesParams = $this->decodeIdsString($request, 'Claroline\ClacoFormBundle\Entity\Entry');

        foreach ($entriesParams as $entryParam) {
            if (!$entryParam->isLocked()) {
                $entries[] = $entryParam;
            }
        }
        foreach ($entries as $entry) {
            $this->clacoFormManager->checkEntryModeration($entry);
        }
        $updatedEntries = $this->clacoFormManager->changeEntriesStatus($entries, intval($status));

        foreach ($updatedEntries as $entry) {
            $serializedEntries[] = $this->entrySerializer->serialize($entry);
        }

        return new JsonResponse($serializedEntries, 200);
    }
834389
public function clearAction(Request $request)
    {
        if (!$this->getParameter('kernel.debug')) {
            throw new AccessDeniedException('You should be in debug mode to access this feature');
        }
        $this->get('victoire_widget.widget_cache')->clear();

        return $this->redirect($request->headers->get('referer'));
    }
497816
public function redirect($route, $parameters = array(), $status = 302, $headers = array())
    {
        return Redirect::route('admin.'.$route, $parameters, $status, $headers);
    }
1319696
public function batchTranslateAction(Request $request)
    {
        if ($this->admin->isGranted('ROLE_SUPER_ADMIN') === false) {
            throw new AccessDeniedException();
        }

        $form = $this->createForm('Networking\InitCmsBundle\Form\Type\PageBatchCopyType', [],
            ['locales' => $this->getParameter('networking_init_cms.page.languages')]);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $data = $form->getData();

            /** @var PageHelper $pageHelper */
            $pageHelper = $this->container->get('networking_init_cms.helper.page_helper');

            $pages = $this->admin->getModelManager()->findBy($this->admin->getClass(), ['locale' => $data['fromLocale']]);
            /** @var PageInterface $page */
            foreach ($pages as $page) {
                $translatedLocales = $page->getTranslatedLocales();

                if (in_array($data['toLocale'], $translatedLocales)) {
                    continue;
                }
                $pageHelper->makeTranslationCopy($page, $data['toLocale']);
            }

            $this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_batch_copy_success');
        }

        return $this->renderWithExtraParams('@NetworkingInitCms/PageAdmin/batch_page_copy.html.twig',
            ['action' => 'batchCopy', 'form' => $form->createView()]
        );
    }
1157652
protected function createRedirect( $path, $status, $headers )
	{
		$redirect = new RedirectResponse( $path, $status, $headers );

		if ( isset( $this->session ) )
			$redirect->setSession( $this->session );

		$redirect->setRequest( $this->generator->getRequest() );

		return $redirect;
	}
1063089
public function redirectGuest($path, $status = 302, $headers = array(), $secure = null)
	{
		return $this->redirector->guest($path, $status, $headers, $secure);
	}
1097340
public function deleteAction(Request $request, $access, Message $message)
    {
        $this->denyAccessUnlessGranted('edit', $message);
        $form = $this->createDeleteForm($message);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrineManager();
            $em->remove($message);
            $em->flush($message);
        }
        if ($this->isRest($access))
            return new JsonResponse(array("status" => "DELETED"),
                Response::HTTP_OK);
        else
            return $this->redirect($request->headers->get('referer'));
    }
870270
public function redirect($url, $status = 302)
    {
        if ($status != 302) {
            $this->setStatus($status);
        }
        $this->setHeader('Location', $url);
        $this->sendHeader();
    }
221002
public function redirect($url, $status = 302)
    {
        $this->_headers['Location'] = (string) $url;
        $this->_status = (integer) $status;

        return $this;
    }
849382
public function draftAction(Request $request)
    {
        $id = $request->get($this->admin->getIdParameter());

        return $this->changePageStatus($id, PageInterface::STATUS_DRAFT);
    }
1313401
protected function commentChangeStatus(ProxyQueryInterface $query, $status)
    {
        if (false === $this->admin->isGranted('EDIT')) {
            throw new AccessDeniedException();
        }

        foreach ($query->execute() as $comment) {
            $comment->setStatus($status);

            $this->admin->getModelManager()->update($comment);
        }

        return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
    }
921355
public function activeStateAction(Request $request, $state, $path = null)
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
        $path = $path ?: $this->activedPath;
        $resource = $this->findOr404($configuration);
        $accessor = PropertyAccess::createPropertyAccessor();
        $accessor->setValue($resource, $path, $this->stringToBoolean($state));

        if ($state) {
            // reset other to false
            $this->repository->bulkUpdate(array($path => false));
            $this->manager->flush();
        }

        if (!$configuration->isHtmlRequest()) {
            return $this->viewHandler->handle($configuration, View::create($resource, 204));
        }

        return $this->redirectHandler->redirectToReferer($configuration);
    }
383615
public function enable($id)
    {
        if (!app('decoy.user')->can('grant', 'admins')) {
            throw new AccessDeniedHttpException;
        }

        if (!($admin = Admin::find($id))) {
            return App::abort(404);
        }

        $admin->active = 1;
        $admin->save();

        return Redirect::back();
    }