public function addTagAction(Request $request, $languageCode, Tag $parentTag = null)
    {
        $this->denyAccessUnlessGranted('ez:tags:add', $parentTag);

        $tagCreateStruct = $this->tagsService->newTagCreateStruct(
            $parentTag ? $parentTag->id : 0,
            $languageCode
        );

        $form = $this->createForm(
            TagCreateType::class,
            $tagCreateStruct,
            [
                'action' => $request->getPathInfo(),
            ]
        );

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $newTag = $this->tagsService->createTag($form->getData());

            $this->addFlashMessage('success', 'tag_added', ['%tagKeyword%' => $newTag->keyword]);

            return $this->redirectToTag($newTag);
        }

        return $this->render(
            '@NetgenTags/admin/tag/add.html.twig',
            [
                'form' => $form->createView(),
                'parentTag' => $parentTag,
            ]
        );
    }
public function addTagAction(Request $request, $languageCode, Tag $parentTag = null)
    {
        $this->denyAccessUnlessGranted('ez:tags:add', $parentTag);

        $tagCreateStruct = $this->tagsService->newTagCreateStruct(
            $parentTag ? $parentTag->id : 0,
            $languageCode
        );

        $form = $this->createForm(
            TagCreateType::class,
            $tagCreateStruct,
            [
                'action' => $request->getPathInfo(),
            ]
        );

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $newTag = $this->tagsService->createTag($form->getData());

            $this->addFlashMessage('success', 'tag_added', ['%tagKeyword%' => $newTag->keyword]);

            return $this->redirectToTag($newTag);
        }

        return $this->render(
            '@NetgenTags/admin/tag/add.html.twig',
            [
                'form' => $form->createView(),
                'parentTag' => $parentTag,
            ]
        );
    }
public function addTagAction ( Request $ request , $ languageCode , Tag $ parentTag = null ) { $ this -> denyAccessUnlessGranted ( 'ez:tags:add' , $ parentTag ) ; $ tagCreateStruct = $ this -> tagsService -> newTagCreateStruct ( $ parentTag ? $ parentTag -> id : 0 , $ languageCode ) ; $ form = $ this -> createForm ( TagCreateType :: class , $ tagCreateStruct , [ 'action' => $ request -> getPathInfo ( ) , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ newTag = $ this -> tagsService -> createTag ( $ form -> getData ( ) ) ; $ this -> addFlashMessage ( 'success' , 'tag_added' , [ '%tagKeyword%' => $ newTag -> keyword ] ) ; return $ this -> redirectToTag ( $ newTag ) ; } return $ this -> render ( '@NetgenTags/admin/tag/add.html.twig' , [ 'form' => $ form -> createView ( ) , 'parentTag' => $ parentTag , ] ) ; }
This method renders view with a form for adding new tag.
After form is being submitted, it stores new tag and redirects to it.

@param \Symfony\Component\HttpFoundation\Request $request
@param string $languageCode
@param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $parentTag

@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
This method renders view with a form for adding new tag . After form is being submitted it stores new tag and redirects to it .