]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/TagController.php
Merge pull request #1774 from wallabag/v2-key-translation
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / TagController.php
index ff4d64a8f4319653961310bbf5ba46d75a30c419..56e5195c1fc0075af5d9896416a5c9f5e5965ee3 100644 (file)
@@ -43,7 +43,7 @@ class TagController extends Controller
 
             $this->get('session')->getFlashBag()->add(
                 'notice',
-                'Tag added'
+                'flashes.tag.notice.tag_added'
             );
 
             return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
@@ -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.
      *