protected function handleWriteTag($request, $id = null)
    {
        $tag = $id ? $this->getTag($id) : null;

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

        FormHelper::removeFields($request->request->all(), $form);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $tag = $form->getData();
            $this->tagManager->save($tag);

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

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

            return $view;
        }

        return $form;
    }
protected function handleWriteTag($request, $id = null)
    {
        $tag = $id ? $this->getTag($id) : null;

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

        FormHelper::removeFields($request->request->all(), $form);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $tag = $form->getData();
            $this->tagManager->save($tag);

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

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

            return $view;
        }

        return $form;
    }
protected function handleWriteTag ( $ request , $ id = null ) { $ tag = $ id ? $ this -> getTag ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_classification_api_form_tag' , $ tag , [ 'csrf_protection' => false , ] ) ; FormHelper :: removeFields ( $ request -> request -> all ( ) , $ form ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ tag = $ form -> getData ( ) ; $ this -> tagManager -> save ( $ tag ) ; $ context = new Context ( ) ; $ context -> setGroups ( [ 'sonata_api_read' ] ) ; $ view = FOSRestView :: create ( $ tag ) ; $ view -> setContext ( $ context ) ; return $ view ; } return $ form ; }
Write a tag, this method is used by both POST and PUT action methods.

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

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