aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/TagController.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-29 14:50:52 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-12-29 14:50:52 +0100
commitfc73222723c7a0c9b577805d3ef51eb96b124b92 (patch)
tree002b77b82266b1e497e3683e72f4a457d4353633 /src/Wallabag/CoreBundle/Controller/TagController.php
parentc997cfcc9c161241a6398b0942a1a869688d807a (diff)
downloadwallabag-fc73222723c7a0c9b577805d3ef51eb96b124b92.tar.gz
wallabag-fc73222723c7a0c9b577805d3ef51eb96b124b92.tar.zst
wallabag-fc73222723c7a0c9b577805d3ef51eb96b124b92.zip
Remove user reference in tag
Fix #1543
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/TagController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index fd2069e0..64d53f0c 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -20,25 +20,23 @@ class TagController extends Controller
20 */ 20 */
21 public function addTagFormAction(Request $request, Entry $entry) 21 public function addTagFormAction(Request $request, Entry $entry)
22 { 22 {
23 $tag = new Tag($this->getUser()); 23 $tag = new Tag();
24 $form = $this->createForm(new NewTagType(), $tag); 24 $form = $this->createForm(new NewTagType(), $tag);
25 $form->handleRequest($request); 25 $form->handleRequest($request);
26 26
27 if ($form->isValid()) { 27 if ($form->isValid()) {
28 $existingTag = $this->getDoctrine() 28 $existingTag = $this->getDoctrine()
29 ->getRepository('WallabagCoreBundle:Tag') 29 ->getRepository('WallabagCoreBundle:Tag')
30 ->findOneByLabelAndUserId($tag->getLabel(), $this->getUser()->getId()); 30 ->findOneByLabel($tag->getLabel());
31 31
32 $em = $this->getDoctrine()->getManager(); 32 $em = $this->getDoctrine()->getManager();
33 33
34 if (is_null($existingTag)) { 34 if (is_null($existingTag)) {
35 $entry->addTag($tag); 35 $entry->addTag($tag);
36 $em->persist($tag); 36 $em->persist($tag);
37 } else { 37 } elseif (!$existingTag->hasEntry($entry)) {
38 if (!$existingTag->hasEntry($entry)) { 38 $entry->addTag($existingTag);
39 $entry->addTag($existingTag); 39 $em->persist($existingTag);
40 $em->persist($existingTag);
41 }
42 } 40 }
43 41
44 $em->flush(); 42 $em->flush();