Handles toggling visibility location of a content item based on submitted form.

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

@return \Symfony\Component\HttpFoundation\Response
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]);
    }
648650
public function toggleAction(Request $request)
    {
        $context = $this->loadContext($request);

        $resource = $context->getResource();

        $this->isGranted('EDIT', $resource);

        if (null !== $field = $request->attributes->get('field')) {
            $accessor = PropertyAccess::createPropertyAccessor();
            $value = $accessor->getValue($resource, $field);
            $accessor->setValue($resource, $field, !$value);

            // TODO use ResourceManager
            $event = $this->getOperator()->update($resource);
            $event->toFlashes($this->getFlashBag());
        }

        // TODO Redirect to parent show

        return $this->redirectToReferer($this->generateUrl(
            $this->config->getRoute('list'),
            $context->getIdentifiers()
        ));
    }
795974
public function updateLayoutBlockSortAction( Request $request ) {
		$zones  = $request->get( 'zones', [] );
		$pageId = $request->get( 'pageId' );
		$code = $request->get( 'code' );

		if ( ! $pageId ) {
			throw $this->createNotFoundException();
		}
		$pageAdmin = $this->container->get( $code );
		foreach ( $zones as $zone ) {
			$zoneName = $zone['zone'];
			if ( array_key_exists( 'layoutBlocks', $zone ) && is_array( $zone['layoutBlocks'] ) ) {
				foreach ( $zone['layoutBlocks'] as $key => $layoutBlockStr ) {
					$sort    = ++ $key;
					$blockId = str_replace( 'layoutBlock_', '', $layoutBlockStr );

					if ( $blockId ) {
						try {
							/** @var \Networking\InitCmsBundle\Model\LayoutBlockInterface $layoutBlock */
							$layoutBlock = $this->admin->getObject( $blockId );
							if ( $layoutBlock ) {
								$layoutBlock->setSortOrder( $sort );
								$layoutBlock->setZone( $zoneName );
							}

							$this->admin->update( $layoutBlock );
						} catch ( \Exception $e ) {
							$message = $e->getMessage();

							return new JsonResponse( [ 'messageStatus' => 'error', 'message' => $message ] );
						}
					}
				}
			}
		}


		$page = $pageAdmin->getModelManager()->find( $pageAdmin->getClass(), $pageId );
		$pageAdmin->setSubject( $page );

		$pageStatus = $this->renderView(
			'@NetworkingInitCms/PageAdmin/page_status_settings.html.twig',
			[ 'admin' => $pageAdmin, 'object' => $page ] );

		$data = [
			'pageStatusSettings' => $pageStatus,
			'pageStatus'         => $this->translate( $page->getStatus() ),
			'messageStatus'      => 'success',
			'message'            => $this->translate( 'message.layout_blocks_sorted', [ 'zone' => '' ] ),
		];

		return new JsonResponse( $data );
	}
112433
public function moveUpAction(Request $request)
    {
        $context = $this->loadContext($request);

        $resource = $context->getResource();

        $this->isGranted('EDIT', $resource);

        $this->move($resource, -1);

        return $this->redirectToReferer($this->generateUrl(
            $this->config->getRoute('list'),
            $context->getIdentifiers()
        ));
    }
629798
public function moveAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

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

        $result = [];
        $mode = $request->request->get('mode');

        if (!in_array($mode, array('before', 'after', 'over'))) {
            $result = array(
                'error'   => true,
                'message' => 'Unexpected creation mode.',
            );
        } else {
            $reference = $this->findFolderById($request->request->get('reference'));

            if ($mode === 'before') {
                $this->getFolderRepository()->persistAsPrevSiblingOf($folder, $reference);
            } elseif ($mode === 'after') {
                $this->getFolderRepository()->persistAsNextSiblingOf($folder, $reference);
            } elseif ($mode === 'over') {
                $this->getFolderRepository()->persistAsLastChildOf($folder, $reference);
            }
            $this->getEntityManager()->flush();
        }

        $response = new Response(json_encode($result, JSON_FORCE_OBJECT));
        $response->headers->add(array('Content-Type' => 'application/json'));
        return $response;
    }
815428
public function editAction(Request $request)
    {
        $entityManager = $this->getDoctrine()->getManager();
        /** @var GlobalConfigRepository $globalConfigRepository */
        $globalConfigRepository = $entityManager->getRepository(GlobalConfig::class);
        $globalConfig = $globalConfigRepository->findLast() ?: new GlobalConfig();
        $form = $this->createForm(GlobalConfigType::class, $globalConfig, []);
        $initialLogo = $globalConfig->getLogo();
        $form->handleRequest($request);

        $success = true;
        if ($form->isSubmitted()) {
            if (true === $success = $form->isValid()) {
                //cloning the entity will give it a new id in order to invalidate browser cache (in meta.html.twig)
                $entityManager->clear(GlobalConfig::class);
                $entityManager->persist($globalConfig);
                $entityManager->flush();
                if ($initialLogo !== $globalConfig->getLogo() && $globalConfig->getLogo() !== null) {
                    $this->container->get(FaviconGenerator::class)->generate(
                        $globalConfig,
                        $this->getParameter('kernel.project_dir').'/faviconConfig.json'
                    );
                }
                $this->congrat('victoire.config.global.edit.success');

                return new JsonResponse([
                    'url'     => $this->generateUrl('victoire_core_homepage_show'),
                    'success' => true,
                ]);
            }
        }

        return new JsonResponse([
            'html' => $this->renderView('VictoireConfigBundle:global:edit.html.twig', [
                'form' => $form->createView(),
            ]),
            'success' => $success,
        ]);
    }
33933
public function editIndexAction(Request $request)
    {
        /* @var $em EntityManager */
        $em = $this->getDoctrine()->getManager();

        /* @var DashboardConfiguration $dashboardConfiguration */
        $dashboardConfiguration = $em
            ->getRepository('KunstmaanAdminBundle:DashboardConfiguration')
            ->findOneBy(array());

        if (is_null($dashboardConfiguration)) {
            $dashboardConfiguration = new DashboardConfiguration();
        }
        $form = $this->createForm(DashboardConfigurationType::class, $dashboardConfiguration);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $em->persist($dashboardConfiguration);
                $em->flush($dashboardConfiguration);

                $this->addFlash(
                    FlashTypes::SUCCESS,
                    $this->get('translator')->trans('kuma_admin.edit.flash.success')
                );

                return new RedirectResponse($this->generateUrl('KunstmaanAdminBundle_homepage'));
            }
        }

        return array(
            'form' => $form->createView(),
            'dashboardConfiguration' => $dashboardConfiguration,
        );
    }
663655
public function toggleSuggestionApproved($request) {

		// Restrict this functionality appropriately.

		$user = Member::currentUserID();
		if(Permission::checkMember($user, 'EXTENSIBLE_SEARCH_SUGGESTIONS') && ($status = $this->service->toggleSuggestionApproved($request->postVar('suggestion')))) {

			// Display an appropriate CMS notification.

			$response = $this->getResponse();
			$response->setStatusCode(204);
			$response->setStatusDescription($status);
			return $status;
		}
		else {
			return $this->httpError(404);
		}
	}
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'));
    }
1145843
public function show(Request $request)
    {
        // AUTHORIZE ... COMES HERE
        $pb = $this->pageblock->where('id', $request->get('pageblock_id'))->first();
        $pageblock = $this->pageBlockRepository->getRenderedByPageBlock($pageblock);
        return $pageblock;
    }
916536
public function toggleProfileAction(Request $request)
    {
        $settingName = $this->getParameter('ongr_settings.active_profiles');
        $manager = $this->get('ongr_settings.settings_manager');

        #TODO Not sure where is the right place to put active profiles setting initiating
        if (!$manager->has($settingName)) {
            $manager->create(
                [
                    'name' => $settingName,
                    'value' => [],
                    'type' => 'hidden',
                ]
            );
        }

        $profileName = $request->get('name');
        $activeProfiles = (array)$manager->getValue($settingName, []);

        $key = array_search($profileName, $activeProfiles);
        if ($key === false) {
            $activeProfiles[] = $profileName;
        } else {
            unset($activeProfiles[$key]);
        }

        $manager->update($settingName, [
            'value' => array_values($activeProfiles)
        ]);

        $this->get('ong_settings.cache_provider')->deleteAll();

        return new JsonResponse(['error' => false]);
    }
814904
public function view($request) {
		$object = null;
		if ($id = $request->param('ID')) {
			$object = ExternalContent::getDataObjectFor($id);
			if ($object instanceof ExternalContentSource) {
				$object = $object->getRoot();
			}

			if ($object && ($object instanceof ExternalContentItem || $object instanceof ExternalContentSource)) {
				$this->data()->setRequestedItem($object);
				$type = $object instanceof ExternalContentItem ? $object->getType() : 'source';
				$template = 'ExternalContent_' . get_class($object) . '_' . $type;

				$viewer = new SSViewer(array($template, 'ExternalContent_' . get_class($object), 'ExternalContent', 'Page'));
				$action = 'view';
				$this->extend('updateViewer', $action, $viewer);

				return $this->customise($object)->renderWith($viewer);
			}
		}

		echo "Template not found for " . ($object ? get_class($object) . ' #' . $object->ID : '');
	}
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'));
    }
688812
public function postAction(Request $request)
    {
        $targetGroup = $this->deserializeData($request->getContent());
        $targetGroup = $this->getTargetGroupRepository()->save($targetGroup);

        $this->getEntityManager()->flush();

        return $this->handleView($this->view($targetGroup));
    }
1037290
public function index(Request $request)
    {
        $input = $request->all();

        $result = $this->repository->paginated();

        return view('cms::modules.images.index')
            ->with('images', $result)
            ->with('pagination', $result->render());
    }
922482
public function layoutAction(Request $request)
    {
        $block = $this->findBlockByRequest($request);

        $data = $request->request->get('data', []);

        try {
            $this->getEditor()->getLayoutAdapter()->updateBlockLayout($block, $data);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

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

        $data = [
            'blocks' => [$this->getViewBuilder()->buildBlock($block)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
133011
public function modalAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $config = $this->buildConfig($request);

        $browser = $this->renderView('EkynaMediaBundle:Manager:render.html.twig', array('config' => $config));

        $modal = new Modal();
        $modal->setTitle('ekyna_media.browser.title.' . $config['mode']);
        $modal->setContent($browser);

        if ($config['mode'] == 'multiple_selection') {
            $modal->setButtons(array(
                array(
                    'id'       => 'submit',
                    'label'    => 'ekyna_core.button.validate',
                    'icon'     => 'glyphicon glyphicon-ok',
                    'cssClass' => 'btn-success',
                    'autospin' => true,
                ),
                array(
                    'id'       => 'close',
                    'label'    => 'ekyna_core.button.close',
                    'icon'     => 'glyphicon glyphicon-remove',
                    'cssClass' => 'btn-default',
                ),
            ));
        }

        return $this->get('ekyna_core.modal')->render($modal);
    }