@Template

@param Request $request
@param ContentTypePage $page

@return array|\Symfony\Component\HttpFoundation\RedirectResponse
779302
public function editAction(Request $request, ContentTypePage $page)
    {
        $form = $this->createEditForm($page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $channel = $this->getSelectedChannel();

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

            $this->get('integrated_page.services.route_cache')->clear();

            $this->get('braincrafted_bootstrap.flash')->success('Page updated');

            return $this->redirectToRoute('integrated_page_content_type_page_index', ['channel' => $channel->getId()]);
        }

        return [
            'page' => $page,
            'form' => $form->createView(),
        ];
    }
819079
public function loadContentTypeByRemoteId(Request $request)
    {
        return $this->contentTypeService->loadContentTypeByRemoteId(
            $request->query->get('remoteId'),
            Language::ALL
        );
    }
1252001
public function getRoutePath(ContentTypePage $page)
    {
        return preg_replace_callback(
            '/(#)([\s\S]+?)(#)/',
            function ($matches) use ($page) {
                return sprintf('{%s}', $matches[2]);
            },
            $page->getPath()
        );
    }
873361
public function xmlAction(Request $request)
    {
        $redis = $this->get('snc_redis.victoire_client');
        $locale = $request->getLocale();
        $cacheKey = "sitemap.$locale";

        $pages = $redis->get($cacheKey);
        if ($pages === null) {
            $exportHandler = $this->get('victoire_sitemap.export.handler');

            $pages = $exportHandler->serialize(
                $exportHandler->handle($locale)
            );
        }

        return $this->render('VictoireSitemapBundle:Sitemap:sitemap.xml.twig', [
            'pages' => json_decode($pages),
        ]);
    }
175469
protected function getResultsTemplate($request)
    {
        $templates = [
            Page::class . '_results',
            Page::class
        ];

        if ($request->getVar('format') == 'rss') {
            array_unshift($templates, Page::class . '_results_rss');
        }

        if ($request->getVar('format') == 'atom') {
            array_unshift($templates, Page::class . '_results_atom');
        }

        return $templates;
    }
987481
public function search(Request $request, array $contenttypes = null)
    {
        $q = '';
        $context = __FUNCTION__;

        if ($request->query->has('q')) {
            $q = $request->query->get('q');
        } elseif ($request->query->has($context)) {
            $q = $request->query->get($context);
        }
        $q = Input::cleanPostedData($q, false);

        $page = $this->app['pager']->getCurrentPage($context);

        // Theme value takes precedence over default config @see https://github.com/bolt/bolt/issues/3951
        $pageSize = $this->getOption('theme/search_results_records', false);
        if ($pageSize === false && !$pageSize = $this->getOption('general/search_results_records', false)) {
            $pageSize = $this->getOption('theme/listing_records', false) ?: $this->getOption('general/listing_records', 10);
        }

        $offset = ($page - 1) * $pageSize;
        $limit = $pageSize;

        // set-up filters from URL
        $filters = [];
        foreach ($request->query->all() as $key => $value) {
            if (strpos($key, '_') > 0) {
                list($contenttypeslug, $field) = explode('_', $key, 2);
                if (isset($filters[$contenttypeslug])) {
                    $filters[$contenttypeslug][$field] = $value;
                } else {
                    $contenttype = $this->getContentType($contenttypeslug);
                    if (is_array($contenttype)) {
                        $filters[$contenttypeslug] = [
                            $field => $value,
                        ];
                    }
                }
            }
        }
        if (count($filters) == 0) {
            $filters = null;
        }

        $isLegacy = $this->getOption('general/compatibility/setcontent_legacy', true);
        if ($isLegacy) {
            $result = $this->storage()->searchContent($q, $contenttypes, $filters, $limit, $offset);

            /** @var \Bolt\Pager\PagerManager $manager */
            $manager = $this->app['pager'];
            $manager
                ->createPager($context)
                ->setCount($result['no_of_results'])
                ->setTotalpages(ceil($result['no_of_results'] / $pageSize))
                ->setCurrent($page)
                ->setShowingFrom($offset + 1)
                ->setShowingTo($offset + ($result ? count($result['results']) : 0));
            ;

            $manager->setLink($this->generateUrl('search', ['q' => $q]) . '&page_search=');
        } else {
            $appCt = array_keys($this->app['query.search_config']->getSearchableTypes());
            $textQuery = '(' . join(',', $appCt) . ')/search';
            $params = [
                'filter' => $q,
                'page'   => $page,
                'limit'  => $pageSize,
            ];
            $searchResult = $this->getContent($textQuery, $params);

            $result = [
                'results' => $searchResult->getSortedResults(),
                'query'   => [
                    'sanitized_q' => strip_tags($q),
                ],
            ];
        }

        $globals = [
            'records'      => $result['results'],
            $context       => $result['query']['sanitized_q'],
            'searchresult' => $result,
        ];

        $template = $this->templateChooser()->search();

        return $this->render($template, [], $globals);
    }
1101442
public function editAction(Request $request, Page $page)
    {
        $form = $this->createEditForm($page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $channel = $this->getSelectedChannel();

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

            $this->get('integrated_page.services.route_cache')->clear();

            $this->get('braincrafted_bootstrap.flash')->success('Page updated');

            return $this->redirect($this->generateUrl('integrated_page_page_index', ['channel' => $channel->getId()]));
        }

        return [
            'page' => $page,
            'form' => $form->createView(),
        ];
    }
1047824
public function listContentTypesForGroup($contentTypeGroupId, Request $request)
    {
        $contentTypes = $this->contentTypeService->loadContentTypes(
            $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId, Language::ALL),
            Language::ALL
        );

        if ($this->getMediaType($request) === 'application/vnd.ez.api.contenttypelist') {
            return new Values\ContentTypeList($contentTypes, $request->getPathInfo());
        }

        return new Values\ContentTypeInfoList($contentTypes, $request->getPathInfo());
    }
1007360
private function createContent(ServerRequestInterface $request)
    {
        $route = $request->getAttribute('route');
        $template = $this->viewInflector->inflect($route);
        $this->templateEngine->parse($template);
        return $this->templateEngine->process($request->getAttribute('viewData', []));
    }
199702
protected function settingsPostAction(Request $request, BasePage $page)
    {
        $entityManager = $this->getDoctrine()->getManager();
        $form = $this->createSettingsForm($page);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $entityManager->persist($page);
            $entityManager->flush();

            $this->congrat($this->get('translator')->trans('victoire_page.update.success', [], 'victoire'));

            return $this->getViewReferenceRedirect($request, $page);
        }

        return [
            'success' => false,
            'message' => $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
            'html'    => $this->get('templating')->render(
                $this->getBaseTemplatePath().':settings.html.twig',
                [
                    'page'               => $page,
                    'form'               => $form->createView(),
                    'businessProperties' => $this->getBusinessProperties($page),
                ]
            ),
        ];
    }
1256517
public function listAction(Request $request): Response
    {
        $deletableContentTypeGroup = [];
        $count = [];

        $page = $request->query->get('page') ?? 1;

        $pagerfanta = new Pagerfanta(
            new ArrayAdapter($this->contentTypeService->loadContentTypeGroups())
        );

        $pagerfanta->setMaxPerPage($this->defaultPaginationLimit);
        $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages()));

        /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup[] $contentTypeGroupList */
        $contentTypeGroupList = $pagerfanta->getCurrentPageResults();

        $deleteContentTypeGroupsForm = $this->formFactory->deleteContentTypeGroups(
            new ContentTypeGroupsDeleteData($this->getContentTypeGroupsNumbers($contentTypeGroupList))
        );

        foreach ($contentTypeGroupList as $contentTypeGroup) {
            $contentTypesCount = count($this->contentTypeService->loadContentTypes($contentTypeGroup));
            $deletableContentTypeGroup[$contentTypeGroup->id] = !(bool)$contentTypesCount;
            $count[$contentTypeGroup->id] = $contentTypesCount;
        }

        return $this->render('@ezdesign/admin/content_type_group/list.html.twig', [
            'pager' => $pagerfanta,
            'form_content_type_groups_delete' => $deleteContentTypeGroupsForm->createView(),
            'deletable' => $deletableContentTypeGroup,
            'content_types_count' => $count,
            'can_create' => $this->isGranted(new Attribute('class', 'create')),
            'can_update' => $this->isGranted(new Attribute('class', 'update')),
            'can_delete' => $this->isGranted(new Attribute('class', 'delete')),
        ]);
    }
1038252
public function edit(Request $request, FormBuilder $formBuilder, $page)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin', 'editor']);

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

        // Get pagetype, or fail..
        $pagetype = PageType::where('model', $page->pagetype_model)->first();

        // Get form fields
        $fields = $pagetype->fields ?: [];

        // Get content
        $content = $page->content;

        // Build the form content[body]
        $form = $formBuilder->createByArray($fields, [
            'method' => 'PUT',
            'url' => route('admin.pages.page.update', $page),
            'name' => 'content',
            'model' => $content
        ]);

        return view('page::pages.edit', [
            'page' => $page,
            'pagetype' => $pagetype,
            'form' => $form
        ]);
    }
447701
public function getContentTypePageUrl(ContentTypePage $page, ContentInterface $document)
    {
        return $this->router->generate(
            $this->getRouteName($page),
            $this->getRoutingParamaters($page, $document)
        );
    }
1301656
public function sitemapPaginatedAction(Request $request, $alias, $page)
    {
        if (null !== ($response = $this->getDumpedSitemapResponse($request, $alias, $page))) {
            return $response;
        }

        $portal = $request->get('_sulu')->getAttribute('portal');
        $localization = $request->get('_sulu')->getAttribute('localization');
        if (!$localization) {
            $localization = $portal->getXDefaultLocalization();
        }

        $sitemap = $this->get('sulu_website.sitemap.xml_renderer')->renderSitemap(
            $alias,
            $page,
            $localization->getLocale(),
            $portal,
            $request->getHttpHost(),
            $request->getScheme()
        );

        if (!$sitemap) {
            return new Response(null, 404);
        }

        return $this->setCacheLifetime(new Response($sitemap));
    }
101049
private function renderPage(Page $page, Request $request)
    {
        return $this->get('synapse')
            ->createDecorator($page)
            ->decorate(array(
                'page' => $page,
                'request' => $request,
            ))
        ;
    }
387469
protected function createEditForm(ContentTypePage $page)
    {
        $channel = $page->getChannel();

        $form = $this->createForm(
            'integrated_page_content_type_page',
            $page,
            [
                'method' => 'PUT',
                'theme'  => $this->getTheme($channel),
                'controller' => $this->get($page->getControllerService()),
            ]
        );

        $form->add('submit', 'submit', ['label' => 'Save']);

        return $form;
    }
863242
public function indexAction(Request $request)
    {
        try {
            $configurator = $this->get('phlexible_element_renderer.configurator');
            $configuration = $configurator->configure($request);
            if ($configuration->hasResponse()) {
                return $configuration->getResponse();
            }
            $data = $configuration->getVariables();

            $template = $data['template'];
            if ($request->attributes->has('template')) {
                $template = $request->attributes->get('template');
            }

            return $this->render($template, (array) $data);

        } catch (NotFoundHttpException $e) {
            $nodeId                 = $this->get('phlexible_siteroot.siteroot_request_matcher')->matchRequest($this->getRequest())->getSpecialTid($request->getLocale(), 'error_' . $e->getStatusCode());
            $contentTreeNode        = $this->get('phlexible_tree.content_tree_manager')->findByTreeId($nodeId)->get($nodeId);
            $url                    = $this->get('router')->generate($contentTreeNode);

            return new RedirectResponse($url);
        }
    }