3 namespace Wallabag\CoreBundle\Controller
;
5 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
6 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
7 use Symfony\Component\HttpFoundation\Request
;
8 use Wallabag\CoreBundle\Entity\Entry
;
9 use Wallabag\CoreBundle\Entity\Tag
;
10 use Wallabag\CoreBundle\Form\Type\NewTagType
;
12 class TagController
extends Controller
15 * @param Request $request
17 * @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag")
19 * @return \Symfony\Component\HttpFoundation\Response
21 public function addTagFormAction(Request
$request, Entry
$entry)
23 $form = $this->createForm(NewTagType
::class, new Tag());
24 $form->handleRequest($request);
26 if ($form->isValid()) {
27 $this->get('wallabag_core.content_proxy')->assignTagsToEntry(
29 $form->get('label')->getData()
32 $em = $this->getDoctrine()->getManager();
36 $this->get('session')->getFlashBag()->add(
38 'flashes.tag.notice.tag_added'
41 return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
44 return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', array(
45 'form' => $form->createView(),
51 * Removes tag from entry.
53 * @Route("/remove-tag/{entry}/{tag}", requirements={"entry" = "\d+", "tag" = "\d+"}, name="remove_tag")
55 * @return \Symfony\Component\HttpFoundation\Response
57 public function removeTagFromEntry(Request
$request, Entry
$entry, Tag
$tag)
59 $entry->removeTag($tag);
60 $em = $this->getDoctrine()->getManager();
62 if (count($tag->getEntries()) == 0) {
67 return $this->redirect($request->headers
->get('referer'));
71 * Shows tags for current user.
73 * @Route("/tag/list", name="tag")
75 * @return \Symfony\Component\HttpFoundation\Response
77 public function showTagAction()
79 $tags = $this->getDoctrine()
80 ->getRepository('WallabagCoreBundle:Tag')
81 ->findTags($this->getUser()->getId());
84 'WallabagCoreBundle:Tag:tags.html.twig',