X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FApiBundle%2FController%2FTagRestController.php;h=c6d6df6a91423718f5006cbace9f569eca6e7a7c;hb=2a1ceb67b4400f46f4d3067e887ff54aa906f0a2;hp=4e7ddc6621baadfa2d756f4495b49e25a2cb6189;hpb=900c844861eac95fc41afbbbc121584b8f9e6c32;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php index 4e7ddc66..c6d6df6a 100644 --- a/src/Wallabag/ApiBundle/Controller/TagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php @@ -3,8 +3,8 @@ namespace Wallabag\ApiBundle\Controller; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Request; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; @@ -25,13 +25,13 @@ class TagRestController extends WallabagRestController ->getRepository('WallabagCoreBundle:Tag') ->findAllTags($this->getUser()->getId()); - $json = $this->get('serializer')->serialize($tags, 'json'); + $json = $this->get('jms_serializer')->serialize($tags, 'json'); return (new JsonResponse())->setJson($json); } /** - * Permanently remove one tag from **every** entry. + * Permanently remove one tag from **every** entry by passing the Tag label. * * @ApiDoc( * requirements={ @@ -44,7 +44,7 @@ class TagRestController extends WallabagRestController public function deleteTagLabelAction(Request $request) { $this->validateAuthentication(); - $label = $request->request->get('tag', ''); + $label = $request->get('tag', ''); $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label); @@ -58,7 +58,7 @@ class TagRestController extends WallabagRestController $this->cleanOrphanTag($tag); - $json = $this->get('serializer')->serialize($tag, 'json'); + $json = $this->get('jms_serializer')->serialize($tag, 'json'); return (new JsonResponse())->setJson($json); } @@ -78,7 +78,7 @@ class TagRestController extends WallabagRestController { $this->validateAuthentication(); - $tagsLabels = $request->request->get('tags', ''); + $tagsLabels = $request->get('tags', ''); $tags = []; @@ -100,13 +100,13 @@ class TagRestController extends WallabagRestController $this->cleanOrphanTag($tags); - $json = $this->get('serializer')->serialize($tags, 'json'); + $json = $this->get('jms_serializer')->serialize($tags, 'json'); return (new JsonResponse())->setJson($json); } /** - * Permanently remove one tag from **every** entry. + * Permanently remove one tag from **every** entry by passing the Tag ID. * * @ApiDoc( * requirements={ @@ -126,23 +126,7 @@ class TagRestController extends WallabagRestController $this->cleanOrphanTag($tag); - $json = $this->get('serializer')->serialize($tag, 'json'); - - return (new JsonResponse())->setJson($json); - } - - /** - * Retrieve version number. - * - * @ApiDoc() - * - * @return JsonResponse - */ - public function getVersionAction() - { - $version = $this->container->getParameter('wallabag_core.version'); - - $json = $this->get('serializer')->serialize($version, 'json'); + $json = $this->get('jms_serializer')->serialize($tag, 'json'); return (new JsonResponse())->setJson($json); } @@ -154,14 +138,14 @@ class TagRestController extends WallabagRestController */ private function cleanOrphanTag($tags) { - if (!is_array($tags)) { + if (!\is_array($tags)) { $tags = [$tags]; } $em = $this->getDoctrine()->getManager(); foreach ($tags as $tag) { - if (count($tag->getEntries()) === 0) { + if (0 === \count($tag->getEntries())) { $em->remove($tag); } }