diff options
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller/WallabagRestController.php')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 74bfe4dc..459c4172 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 | ||
@@ -175,8 +174,8 @@ class WallabagRestController extends FOSRestController | |||
175 | $this->validateUserAccess($entry->getUser()->getId()); | 174 | $this->validateUserAccess($entry->getUser()->getId()); |
176 | 175 | ||
177 | $title = $request->request->get('title'); | 176 | $title = $request->request->get('title'); |
178 | $isArchived = $request->request->get('is_archived'); | 177 | $isArchived = $request->request->get('archive'); |
179 | $isStarred = $request->request->get('is_starred'); | 178 | $isStarred = $request->request->get('star'); |
180 | 179 | ||
181 | if (!is_null($title)) { | 180 | if (!is_null($title)) { |
182 | $entry->setTitle($title); | 181 | $entry->setTitle($title); |
@@ -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,11 +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()); | ||
332 | 335 | ||
333 | $em = $this->getDoctrine()->getManager(); | 336 | $this->getDoctrine() |
334 | $em->remove($tag); | 337 | ->getRepository('WallabagCoreBundle:Entry') |
335 | $em->flush(); | 338 | ->removeTag($this->getUser()->getId(), $tag); |
336 | 339 | ||
337 | $json = $this->get('serializer')->serialize($tag, 'json'); | 340 | $json = $this->get('serializer')->serialize($tag, 'json'); |
338 | 341 | ||