Save Page settings.
Route is defined in inherited controllers.

@param Request  $request
@param BasePage $page

@return array|Response
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),
                ]
            ),
        ];
    }
779768
public function postTitle(Request $request, Page $page)
    {
        $this->authorize('edit', $page);

        $oldTitle = $page->getTitle();
        $page->setTitle($request->input('title'));

        Event::fire(new Events\PageTitleWasChanged($page, $oldTitle, $page->getTitle()));

        return [
            'status'   => $page->getCurrentVersion()->getStatus(),
            'location' => (string) URLFacade::page($page),
        ];
    }
1265870
public function postSortChildren(Request $request, Page $page)
    {
        $this->authorize('editChildrenBasic', $page);

        Bus::dispatch(new ReorderChildPages($page, $request->input('sequences')));
    }
89366
public function getAncestorsAction(Page $page)
    {
        $ancestors = $this->getPageRepository()->getAncestors($page);

        return $this->createResponse($this->formatCollection($ancestors));
    }
141616
public function getPageUrl(Page $page)
    {
        return $this->config['base_url'].'/'.
            ($page->getSubFolder() === null ? '' : $page->getSubFolder().'/').
            $this->getPagePublishFilename($page);
    }
518166
public function saveAction(Request $request)
    {
        $siterootSaver = $this->get('phlexible_siteroot.siteroot_saver');

        $siterootSaver->saveAction($request);

        return new ResultResponse(true, 'Siteroot data saved');
    }
163318
public function create(Page &$page)
    {
        $data = $page->exportData();
        $endpoint= '/admin/pages.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'page' => $data
            )
        );
        $page->setData($response['page']);
    }
213335
public function edit(PageRequest $request, Page $page)
    {
        return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('page::page.name'))
            ->view('page::admin.page.edit')
            ->data(compact('page'))
            ->output();
    }
1287830
public function update(Request $request, FormBuilder $formBuilder, $page)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin', 'editor']);

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

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

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

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

        // It will automatically use current request, get the rules, and do the validation
        if (!$form->isValid()) {
            return redirect()->back()->withErrors($form->getErrors())->withInput();
        }

        // Page data
        $page->title = $request->input('title');
        $page->content = $request->input('content');
        $page->status = $request->input('status') ? 2 : 1;

        $page->update();

        flash('The page was successfully updated')->success();

        return redirect()->route('admin.pages.index');
    }
1104519
public function getPageBlocksByRequest(Request $request)
    {
        $routeName = $request->get('_route');
        $pageName = $this->routeConfig->getPageName($routeName);

        if (!isset($this->pageBlocks[$pageName])) {
            throw new \Exception(
                sprintf(
                    'Not found blocs for page with name \'%s\' and route name \'%s\'',
                    $pageName,
                    $routeName
                )
            );
        }
        $blocks = $this->pageBlocks[$pageName];

        // add route_params to blocks
        foreach ($blocks as $index => $block) {
            $blocks[$index]['settings']['route_params'] = $request->get('_route_params');
        }

        return $blocks;
    }
824365
public function store(Request $request)
	{
		$attributes = request()->validate(Settings::$rules, Settings::$messages);

        $setting = $this->createEntry(Settings::class, $attributes);

        log_activity('Setting Created', 'A Setting was successfully created', $setting);

        return redirect_to_resource();
	}
1081395
public function setRequest(Request $request)
    {
        $this->request = $request;

        $this->cachedRoot = null;
        $this->cachedScheme = null;
        $this->routeGenerator = null;
    }
307372
public function changePriorityAction(Request $request, BasePage $page)
    {
        $em = $this->get('doctrine.orm.entity_manager');

        $pageSeo = $page->getSeo() ?: new PageSeo();
        $pageSeo->setCurrentLocale($request->getLocale());

        $form = $this->createSitemapPriorityType($page, $pageSeo);
        $form->handleRequest($request);
        $params = [
            'success' => $form->isValid(),
        ];

        if ($form->isValid()) {
            $page->setSeo($pageSeo);
            $em->persist($pageSeo);
            $em->flush();
        }

        return new JsonResponse($params);
    }
540941
public function store(ImageFormRequest $request, Page $page): void
    {
        $page->addMediaFromRequest('file')
             ->sanitizingFileName(function ($fileName) {
                 return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION);
             })
             ->toMediaCollection('default', config('cortex.pages.media.disk'));
    }
107745
public function putMetadataAction(Page $page, Request $request)
    {
        $metadatas = $this->application
                ->getContainer()
                ->get('nestednode.metadata.resolver')
                ->resolve($page);

        foreach ($request->request->all() as $name => $attributes) {
            if ($metadatas->has($name)) {
                foreach ($attributes as $attr_name => $attr_value) {
                    if ($attr_value !== $metadatas->get($name)->getAttribute($attr_name)) {
                        $metadatas->get($name)->setAttribute($attr_name, $attr_value, null, false);
                    }
                }
            }
        }

        $page->setMetaData($metadatas);
        $this->getApplication()->getEntityManager()->flush();

        return $this->createJsonResponse(null, 204);
    }
360082
public function update(PageRequest $request, Page $page)
    {
        try {
            $attributes = $request->all();

            $page->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('page::page.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('page/page/' . $page->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('page/page/' . $page->getRouteKey()))
                ->redirect();
        }

    }
1302496
public function handleForm(FormPageInterface $page, Request $request, RenderContext $context)
    {
        /* @var $em EntityManager */
        $em = $this->container->get('doctrine.orm.entity_manager');
        /* @var $formBuilder FormBuilderInterface */
        $formBuilder = $this->container->get('form.factory')->createBuilder(FormType::class);
        /* @var $router RouterInterface */
        $router = $this->container->get('router');
        /* @var $fields ArrayObject */
        $fields = new ArrayObject();
        $pageParts = $em->getRepository('KunstmaanPagePartBundle:PagePartRef')->getPageParts($page, $page->getFormElementsContext());
        foreach ($pageParts as $sequence => $pagePart) {
            if ($pagePart instanceof FormAdaptorInterface) {
                $pagePart->adaptForm($formBuilder, $fields, $sequence);
            }
        }

        $form = $formBuilder->getForm();
        if ($request->getMethod() == 'POST') {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $formSubmission = new FormSubmission();
                $formSubmission->setIpAddress($request->getClientIp());
                $formSubmission->setNode($em->getRepository('KunstmaanNodeBundle:Node')->getNodeFor($page));
                $formSubmission->setLang($request->getLocale());
                $em->persist($formSubmission);

                /* @var $field FormSubmissionField */
                foreach ($fields as $field) {
                    $field->setSubmission($formSubmission);
                    $field->onValidPost($form, $formBuilder, $request, $this->container);
                    $em->persist($field);
                }

                $em->flush();
                $em->refresh($formSubmission);

                $event = new SubmissionEvent($formSubmission, $page);
                $this->container->get('event_dispatcher')->dispatch(FormEvents::ADD_SUBMISSION, $event);

                return new RedirectResponse($page->generateThankYouUrl($router, $context));
            }
        }
        $context['frontendform'] = $form->createView();
        $context['frontendformobject'] = $form;

        return null;
    }