public function convertToSynonymAction(Request $request, Tag $tag)
    {
        $this->denyAccessUnlessGranted('ez:tags:makesynonym');

        $form = $this->createForm(
            TagConvertType::class,
            null,
            [
                'tag' => $tag,
                'action' => $request->getPathInfo(),
            ]
        );

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $mainTag = $this->tagsService->loadTag($form->getData()['mainTag']);

            $this->tagsService->convertToSynonym($tag, $mainTag);

            $this->addFlashMessage(
                'success',
                'tag_converted',
                [
                    '%tagKeyword%' => $tag->keyword,
                    '%mainTagKeyword%' => $mainTag->keyword,
                ]
            );

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

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

        $form = $this->createForm(
            TagConvertType::class,
            null,
            [
                'tag' => $tag,
                'action' => $request->getPathInfo(),
            ]
        );

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $mainTag = $this->tagsService->loadTag($form->getData()['mainTag']);

            $this->tagsService->convertToSynonym($tag, $mainTag);

            $this->addFlashMessage(
                'success',
                'tag_converted',
                [
                    '%tagKeyword%' => $tag->keyword,
                    '%mainTagKeyword%' => $mainTag->keyword,
                ]
            );

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

        return $this->render(
            '@NetgenTags/admin/tag/convert.html.twig',
            [
                'form' => $form->createView(),
                'tag' => $tag,
            ]
        );
    }
public function convertToSynonymAction ( Request $ request , Tag $ tag ) { $ this -> denyAccessUnlessGranted ( 'ez:tags:makesynonym' ) ; $ form = $ this -> createForm ( TagConvertType :: class , null , [ 'tag' => $ tag , 'action' => $ request -> getPathInfo ( ) , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ mainTag = $ this -> tagsService -> loadTag ( $ form -> getData ( ) [ 'mainTag' ] ) ; $ this -> tagsService -> convertToSynonym ( $ tag , $ mainTag ) ; $ this -> addFlashMessage ( 'success' , 'tag_converted' , [ '%tagKeyword%' => $ tag -> keyword , '%mainTagKeyword%' => $ mainTag -> keyword , ] ) ; return $ this -> redirectToTag ( $ mainTag ) ; } return $ this -> render ( '@NetgenTags/admin/tag/convert.html.twig' , [ 'form' => $ form -> createView ( ) , 'tag' => $ tag , ] ) ; }
This method is called for convert tag to synonym action.
It shows a confirmation view.
If form has been submitted, it converts the tag to synonym and redirects to newly created synonym.

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

@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
This method is called for convert tag to synonym action . It shows a confirmation view . If form has been submitted it converts the tag to synonym and redirects to newly created synonym .