protected function handleWriteGroup($request, $id = null)
    {
        $groupClassName = $this->groupManager->getClass();
        $group = $id ? $this->getGroup($id) : new $groupClassName('');

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

        $form->handleRequest($request);

        if ($form->isValid()) {
            $group = $form->getData();
            $this->groupManager->updateGroup($group);

            $context = new Context();
            $context->setGroups(['sonata_api_read']);
            $context->enableMaxDepth();

            $view = FOSRestView::create($group);
            $view->setContext($context);

            return $view;
        }

        return $form;
    }
protected function handleWriteGroup($request, $id = null)
    {
        $groupClassName = $this->groupManager->getClass();
        $group = $id ? $this->getGroup($id) : new $groupClassName('');

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

        $form->handleRequest($request);

        if ($form->isValid()) {
            $group = $form->getData();
            $this->groupManager->updateGroup($group);

            $context = new Context();
            $context->setGroups(['sonata_api_read']);
            $context->enableMaxDepth();

            $view = FOSRestView::create($group);
            $view->setContext($context);

            return $view;
        }

        return $form;
    }
protected function handleWriteGroup ( $ request , $ id = null ) { $ groupClassName = $ this -> groupManager -> getClass ( ) ; $ group = $ id ? $ this -> getGroup ( $ id ) : new $ groupClassName ( '' ) ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_user_api_form_group' , $ group , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ group = $ form -> getData ( ) ; $ this -> groupManager -> updateGroup ( $ group ) ; $ context = new Context ( ) ; $ context -> setGroups ( [ 'sonata_api_read' ] ) ; $ context -> enableMaxDepth ( ) ; $ view = FOSRestView :: create ( $ group ) ; $ view -> setContext ( $ context ) ; return $ view ; } return $ form ; }
Write a Group, this method is used by both POST and PUT action methods.

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

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