src/Controller/Api/PageController.php
/**
     * Write a page, this method is used by both POST and PUT action methods.
     *
     * @param Request     $request Symfony request
     * @param string|null $id      Page identifier
     *
     * @return FormInterface
     */
Write a page, this method is used by both POST and PUT action methods.
@param Request     $request Symfony request
@param string|null $id      Page identifier


Write a page this method is used by both POST and PUT action methods . @param Request $request Symfony request @param string|null $id Page identifier
protected function handleWritePage($request, $id = null)
    {
        $page = $id ? $this->getPage($id) : null;
        $form = $this->formFactory->createNamed(null, 'sonata_page_api_form_page', $page, [
            'csrf_protection' => false,
        ]);
        $form->handleRequest($request);
        if ($form->isValid()) {
            $page = $form->getData();
            $this->pageManager->save($page);
            return $this->serializeContext($page, ['sonata_api_read']);
        }
        return $form;
    }
protected function handleWritePage ( $ request , $ id = null ) { $ page = $ id ? $ this -> getPage ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_page_api_form_page' , $ page , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ page = $ form -> getData ( ) ; $ this -> pageManager -> save ( $ page ) ; return $ this -> serializeContext ( $ page , [ 'sonata_api_read' ] ) ; } return $ form ; }
Write a page, this method is used by both POST and PUT action methods.
Write a page this method is used by both POST and PUT action methods .