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


Write a site this method is used by both POST and PUT action methods . @param Request $request Symfony request @param string|null $id Site identifier
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.
Write a site this method is used by both POST and PUT action methods .