aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2016-01-02 12:46:52 +0100
committerNicolas Lœuillet <nicolas@loeuillet.org>2016-01-02 12:46:52 +0100
commitdad1c546a521159ca65a5a7649651d37728f0e55 (patch)
treef1d59eb83b45adb83bb21726374133a399d3c740 /src/Wallabag/CoreBundle/Controller
parent5432f6150939af6e7d2e8bf0faea0576491aaed0 (diff)
parent6be9750155fa731d75898b4973a126a090345c2d (diff)
downloadwallabag-dad1c546a521159ca65a5a7649651d37728f0e55.tar.gz
wallabag-dad1c546a521159ca65a5a7649651d37728f0e55.tar.zst
wallabag-dad1c546a521159ca65a5a7649651d37728f0e55.zip
Merge pull request #1545 from wallabag/v2-user-tag
v2 – Remove user reference in tag
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-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();