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

        $tagIds = $request->request->has('Tags') ?
            $request->request->get('Tags') :
            $this->get('session')->get('ngtags_tag_ids');

        if (empty($tagIds)) {
            return $this->redirectToTag($parentTag);
        }

        $tags = [];
        foreach ($tagIds as $tagId) {
            $tags[] = $this->tagsService->loadTag($tagId);
        }

        if ($request->request->has('DeleteTagsButton')) {
            if (!$this->isCsrfTokenValid('eztags_admin', $request->request->get('_csrf_token'))) {
                $this->addFlashMessage('errors', 'invalid_csrf_token');

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

            foreach ($tags as $tagObject) {
                $this->tagsService->deleteTag($tagObject);
            }

            $this->addFlashMessage('success', 'tags_deleted');

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

        return $this->render(
            '@NetgenTags/admin/tag/delete_tags.html.twig',
            [
                'parentTag' => $parentTag ?: null,
                'tags' => $tags,
            ]
        );
    }
public function deleteTagsAction(Request $request, Tag $parentTag = null)
    {
        $this->denyAccessUnlessGranted('ez:tags:delete');

        $tagIds = $request->request->has('Tags') ?
            $request->request->get('Tags') :
            $this->get('session')->get('ngtags_tag_ids');

        if (empty($tagIds)) {
            return $this->redirectToTag($parentTag);
        }

        $tags = [];
        foreach ($tagIds as $tagId) {
            $tags[] = $this->tagsService->loadTag($tagId);
        }

        if ($request->request->has('DeleteTagsButton')) {
            if (!$this->isCsrfTokenValid('eztags_admin', $request->request->get('_csrf_token'))) {
                $this->addFlashMessage('errors', 'invalid_csrf_token');

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

            foreach ($tags as $tagObject) {
                $this->tagsService->deleteTag($tagObject);
            }

            $this->addFlashMessage('success', 'tags_deleted');

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

        return $this->render(
            '@NetgenTags/admin/tag/delete_tags.html.twig',
            [
                'parentTag' => $parentTag ?: null,
                'tags' => $tags,
            ]
        );
    }
public function deleteTagsAction ( Request $ request , Tag $ parentTag = null ) { $ this -> denyAccessUnlessGranted ( 'ez:tags:delete' ) ; $ tagIds = $ request -> request -> has ( 'Tags' ) ? $ request -> request -> get ( 'Tags' ) : $ this -> get ( 'session' ) -> get ( 'ngtags_tag_ids' ) ; if ( empty ( $ tagIds ) ) { return $ this -> redirectToTag ( $ parentTag ) ; } $ tags = [ ] ; foreach ( $ tagIds as $ tagId ) { $ tags [ ] = $ this -> tagsService -> loadTag ( $ tagId ) ; } if ( $ request -> request -> has ( 'DeleteTagsButton' ) ) { if ( ! $ this -> isCsrfTokenValid ( 'eztags_admin' , $ request -> request -> get ( '_csrf_token' ) ) ) { $ this -> addFlashMessage ( 'errors' , 'invalid_csrf_token' ) ; return $ this -> redirectToTag ( $ parentTag ) ; } foreach ( $ tags as $ tagObject ) { $ this -> tagsService -> deleteTag ( $ tagObject ) ; } $ this -> addFlashMessage ( 'success' , 'tags_deleted' ) ; return $ this -> redirectToTag ( $ parentTag ) ; } return $ this -> render ( '@NetgenTags/admin/tag/delete_tags.html.twig' , [ 'parentTag' => $ parentTag ? : null , 'tags' => $ tags , ] ) ; }
This method is called from a form containing all children tags of a tag.
It shows a confirmation view.
If form has been submitted, it deletes selected children tags.

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

@return \Symfony\Component\HttpFoundation\Response
This method is called from a form containing all children tags of a tag . It shows a confirmation view . If form has been submitted it deletes selected children tags .