aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle
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/ApiBundle
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/ApiBundle')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php17
-rw-r--r--src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php3
2 files changed, 14 insertions, 6 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 74bfe4dc..587013f6 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -27,7 +27,7 @@ class WallabagRestController extends FOSRestController
27 ->findOneByLabel($label); 27 ->findOneByLabel($label);
28 28
29 if (is_null($tagEntity)) { 29 if (is_null($tagEntity)) {
30 $tagEntity = new Tag($this->getUser()); 30 $tagEntity = new Tag();
31 $tagEntity->setLabel($label); 31 $tagEntity->setLabel($label);
32 } 32 }
33 33
@@ -74,8 +74,7 @@ class WallabagRestController extends FOSRestController
74 $perPage = (int) $request->query->get('perPage', 30); 74 $perPage = (int) $request->query->get('perPage', 30);
75 $tags = $request->query->get('tags', []); 75 $tags = $request->query->get('tags', []);
76 76
77 $pager = $this 77 $pager = $this->getDoctrine()
78 ->getDoctrine()
79 ->getRepository('WallabagCoreBundle:Entry') 78 ->getRepository('WallabagCoreBundle:Entry')
80 ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order); 79 ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order);
81 80
@@ -311,7 +310,12 @@ class WallabagRestController extends FOSRestController
311 public function getTagsAction() 310 public function getTagsAction()
312 { 311 {
313 $this->validateAuthentication(); 312 $this->validateAuthentication();
314 $json = $this->get('serializer')->serialize($this->getUser()->getTags(), 'json'); 313
314 $tags = $this->getDoctrine()
315 ->getRepository('WallabagCoreBundle:Tag')
316 ->findAllTags($this->getUser()->getId());
317
318 $json = $this->get('serializer')->serialize($tags, 'json');
315 319
316 return $this->renderJsonResponse($json); 320 return $this->renderJsonResponse($json);
317 } 321 }
@@ -328,7 +332,10 @@ class WallabagRestController extends FOSRestController
328 public function deleteTagAction(Tag $tag) 332 public function deleteTagAction(Tag $tag)
329 { 333 {
330 $this->validateAuthentication(); 334 $this->validateAuthentication();
331 $this->validateUserAccess($tag->getUser()->getId()); 335
336 $this->getDoctrine()
337 ->getRepository('WallabagCoreBundle:Entry')
338 ->removeTag($this->getUser()->getId(), $tag);
332 339
333 $em = $this->getDoctrine()->getManager(); 340 $em = $this->getDoctrine()->getManager();
334 $em->remove($tag); 341 $em->remove($tag);
diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php
index bdd36e0c..a7120e83 100644
--- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php
+++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php
@@ -208,7 +208,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
208 208
209 $tags = array(); 209 $tags = array();
210 foreach ($entry->getTags() as $tag) { 210 foreach ($entry->getTags() as $tag) {
211 $tags[] = array('id' => $tag->getId(), 'label' => $tag->getLabel()); 211 $tags[] = array('id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug());
212 } 212 }
213 213
214 $this->client->request('GET', '/api/entries/'.$entry->getId().'/tags'); 214 $this->client->request('GET', '/api/entries/'.$entry->getId().'/tags');
@@ -309,5 +309,6 @@ class WallabagRestControllerTest extends WallabagApiTestCase
309 309
310 $this->assertArrayHasKey('label', $content); 310 $this->assertArrayHasKey('label', $content);
311 $this->assertEquals($tag['label'], $content['label']); 311 $this->assertEquals($tag['label'], $content['label']);
312 $this->assertEquals($tag['slug'], $content['slug']);
312 } 313 }
313} 314}