src/Controller/Api/SiteController.php
protected function handleWriteSite($request, $id = null)
    {
        $site = $id ? $this->getSite($id) : null;

        $form = $this->formFactory->createNamed(null, 'sonata_page_api_form_site', $site, [
            'csrf_protection' => false,
        ]);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $site = $form->getData();

            $this->siteManager->save($site);

            return $this->serializeContext($site, ['sonata_api_read']);
        }

        return $form;
    }
protected function handleWriteSite($request, $id = null)
    {
        $site = $id ? $this->getSite($id) : null;

        $form = $this->formFactory->createNamed(null, 'sonata_page_api_form_site', $site, [
            'csrf_protection' => false,
        ]);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $site = $form->getData();

            $this->siteManager->save($site);

            return $this->serializeContext($site, ['sonata_api_read']);
        }

        return $form;
    }
protected function handleWriteSite ( $ request , $ id = null ) { $ site = $ id ? $ this -> getSite ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_page_api_form_site' , $ site , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ site = $ form -> getData ( ) ; $ this -> siteManager -> save ( $ site ) ; return $ this -> serializeContext ( $ site , [ 'sonata_api_read' ] ) ; } return $ form ; }
Write a site, this method is used by both POST and PUT action methods.

@param Request  $request Symfony request
@param int|null $id      A post identifier

@return FormInterface|FOSRestView
Write a site this method is used by both POST and PUT action methods .