aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 03eb9b08..869fdc56 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -334,6 +334,77 @@ class WallabagRestController extends FOSRestController
334 * 334 *
335 * @ApiDoc( 335 * @ApiDoc(
336 * requirements={ 336 * requirements={
337 * {"name"="tag", "dataType"="string", "required"=true, "requirement"="\w+", "description"="Tag as a string"}
338 * }
339 * )
340 *
341 * @return Response
342 */
343 public function deleteTagLabelAction(Request $request)
344 {
345 $this->validateAuthentication();
346 $label = $request->request->get('tag', '');
347
348 $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label);
349
350 if (empty($tag)) {
351 throw $this->createNotFoundException('Tag not found');
352 }
353
354 $this->getDoctrine()
355 ->getRepository('WallabagCoreBundle:Entry')
356 ->removeTag($this->getUser()->getId(), $tag);
357
358 $json = $this->get('serializer')->serialize($tag, 'json');
359
360 return $this->renderJsonResponse($json);
361 }
362
363 /**
364 * Permanently remove some tags from **every** entry.
365 *
366 * @ApiDoc(
367 * requirements={
368 * {"name"="tags", "dataType"="string", "required"=true, "format"="tag1,tag2", "description"="Tags as strings (comma splitted)"}
369 * }
370 * )
371 *
372 * @return Response
373 */
374 public function deleteTagsLabelAction(Request $request)
375 {
376 $this->validateAuthentication();
377
378 $tagsLabels = $request->request->get('tags', '');
379
380 $tags = [];
381
382 foreach (explode(',', $tagsLabels) as $tagLabel) {
383 $tagEntity = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel);
384
385 if (!empty($tagEntity)) {
386 $tags[] = $tagEntity;
387 }
388 }
389
390 if (empty($tags)) {
391 throw $this->createNotFoundException('Tags not found');
392 }
393
394 $this->getDoctrine()
395 ->getRepository('WallabagCoreBundle:Entry')
396 ->removeTags($this->getUser()->getId(), $tags);
397
398 $json = $this->get('serializer')->serialize($tags, 'json');
399
400 return $this->renderJsonResponse($json);
401 }
402
403 /**
404 * Permanently remove one tag from **every** entry.
405 *
406 * @ApiDoc(
407 * requirements={
337 * {"name"="tag", "dataType"="integer", "requirement"="\w+", "description"="The tag"} 408 * {"name"="tag", "dataType"="integer", "requirement"="\w+", "description"="The tag"}
338 * } 409 * }
339 * ) 410 * )
@@ -352,6 +423,7 @@ class WallabagRestController extends FOSRestController
352 423
353 return $this->renderJsonResponse($json); 424 return $this->renderJsonResponse($json);
354 } 425 }
426
355 /** 427 /**
356 * Retrieve version number. 428 * Retrieve version number.
357 * 429 *