diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-06-25 18:37:41 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-08-23 07:26:58 +0200 |
commit | 4da01f492b20312461d3f4f612a98e3b52c76fa9 (patch) | |
tree | 1084c9b0b801cb0f43b4c0918c43826d559c70f7 /src/Wallabag/ApiBundle | |
parent | e71cef0bb81c80575f38c4ea040716efdfcb17f0 (diff) | |
download | wallabag-4da01f492b20312461d3f4f612a98e3b52c76fa9.tar.gz wallabag-4da01f492b20312461d3f4f612a98e3b52c76fa9.tar.zst wallabag-4da01f492b20312461d3f4f612a98e3b52c76fa9.zip |
Delete tag or tags by label
Tests not included
Diffstat (limited to 'src/Wallabag/ApiBundle')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 61 |
1 files changed, 61 insertions, 0 deletions
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 | |||
352 | 352 | ||
353 | return $this->renderJsonResponse($json); | 353 | return $this->renderJsonResponse($json); |
354 | } | 354 | } |
355 | |||
356 | /** | ||
357 | * Permanently remove one tag from **every** entry. | ||
358 | * | ||
359 | * @ApiDoc( | ||
360 | * requirements={ | ||
361 | * {"name"="tag", "dataType"="string", "requirement"="\w+", "description"="The tag as a string"} | ||
362 | * } | ||
363 | * ) | ||
364 | * | ||
365 | * @return Response | ||
366 | */ | ||
367 | public function deleteTagLabelAction(Request $request) | ||
368 | { | ||
369 | $this->validateAuthentication(); | ||
370 | $label = $request->query->get('tag',''); | ||
371 | |||
372 | $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label); | ||
373 | $this->getDoctrine() | ||
374 | ->getRepository('WallabagCoreBundle:Entry') | ||
375 | ->removeTag($this->getUser()->getId(), $tag); | ||
376 | |||
377 | $json = $this->get('serializer')->serialize($tag, 'json'); | ||
378 | |||
379 | return $this->renderJsonResponse($json); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Permanently remove some tags from **every** entry. | ||
384 | * | ||
385 | * @ApiDoc( | ||
386 | * requirements={ | ||
387 | * {"name"="tags", "dataType"="string", "required"=true, "format"="tag1,tag2", "description"="The tags as strings"} | ||
388 | * } | ||
389 | * ) | ||
390 | * | ||
391 | * @return Response | ||
392 | */ | ||
393 | public function deleteTagsLabelAction(Request $request) | ||
394 | { | ||
395 | $this->validateAuthentication(); | ||
396 | |||
397 | $tagsLabels = $request->query->get('tags', ''); | ||
398 | |||
399 | $tags = array(); | ||
400 | |||
401 | foreach (explode(',', $tagsLabels) as $tagLabel) { | ||
402 | $tagEntity = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel); | ||
403 | $tags[] = $tagEntity; | ||
404 | } | ||
405 | |||
406 | $this->getDoctrine() | ||
407 | ->getRepository('WallabagCoreBundle:Entry') | ||
408 | ->removeTags($this->getUser()->getId(), $tags); | ||
409 | |||
410 | $json = $this->get('serializer')->serialize($tags, 'json'); | ||
411 | |||
412 | return $this->renderJsonResponse($json); | ||
413 | } | ||
414 | |||
415 | |||
355 | /** | 416 | /** |
356 | * Retrieve version number. | 417 | * Retrieve version number. |
357 | * | 418 | * |