From 567421af5019bf5937aa2b4214b405d87a1f1f86 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 10 Feb 2016 17:41:28 +0100 Subject: remove tag from entry #1377 --- src/Wallabag/CoreBundle/Controller/TagController.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Wallabag/CoreBundle/Controller/TagController.php') diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index ff4d64a8..7b34939d 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -55,6 +55,26 @@ class TagController extends Controller )); } + /** + * Removes tag from entry. + * + * @Route("/remove-tag/{entry}/{tag}", requirements={"entry" = "\d+", "tag" = "\d+"}, name="remove_tag") + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function removeTagFromEntry(Request $request, Entry $entry, Tag $tag) + { + $entry->removeTag($tag); + $em = $this->getDoctrine()->getManager(); + $em->flush(); + if (count($tag->getEntries()) == 0) { + $em->remove($tag); + } + $em->flush(); + + return $this->redirect($request->headers->get('referer')); + } + /** * Shows tags for current user. * -- cgit v1.2.3