X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FApiBundle%2FController%2FWallabagRestController.php;h=8eaff5f6b0c1610a18ed989aa1dd427584f03660;hb=4da01f492b20312461d3f4f612a98e3b52c76fa9;hp=03eb9b0848272381bfbc3dd550c476068d55dcd3;hpb=e71cef0bb81c80575f38c4ea040716efdfcb17f0;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 03eb9b08..8eaff5f6 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -352,6 +352,67 @@ class WallabagRestController extends FOSRestController return $this->renderJsonResponse($json); } + + /** + * Permanently remove one tag from **every** entry. + * + * @ApiDoc( + * requirements={ + * {"name"="tag", "dataType"="string", "requirement"="\w+", "description"="The tag as a string"} + * } + * ) + * + * @return Response + */ + public function deleteTagLabelAction(Request $request) + { + $this->validateAuthentication(); + $label = $request->query->get('tag',''); + + $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label); + $this->getDoctrine() + ->getRepository('WallabagCoreBundle:Entry') + ->removeTag($this->getUser()->getId(), $tag); + + $json = $this->get('serializer')->serialize($tag, 'json'); + + return $this->renderJsonResponse($json); + } + + /** + * Permanently remove some tags from **every** entry. + * + * @ApiDoc( + * requirements={ + * {"name"="tags", "dataType"="string", "required"=true, "format"="tag1,tag2", "description"="The tags as strings"} + * } + * ) + * + * @return Response + */ + public function deleteTagsLabelAction(Request $request) + { + $this->validateAuthentication(); + + $tagsLabels = $request->query->get('tags', ''); + + $tags = array(); + + foreach (explode(',', $tagsLabels) as $tagLabel) { + $tagEntity = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel); + $tags[] = $tagEntity; + } + + $this->getDoctrine() + ->getRepository('WallabagCoreBundle:Entry') + ->removeTags($this->getUser()->getId(), $tags); + + $json = $this->get('serializer')->serialize($tags, 'json'); + + return $this->renderJsonResponse($json); + } + + /** * Retrieve version number. *