diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-20 16:38:24 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-03-06 20:50:30 +0100 |
commit | 2691cf04384239c546e141af6cc3c22b210dae58 (patch) | |
tree | 0e3f7047e7edb9628139a7f344ea646f660ac14d /src/Wallabag/CoreBundle/Controller | |
parent | 1d14779154481b320e1c44fccf2558d8c9fa43a1 (diff) | |
download | wallabag-2691cf04384239c546e141af6cc3c22b210dae58.tar.gz wallabag-2691cf04384239c546e141af6cc3c22b210dae58.tar.zst wallabag-2691cf04384239c546e141af6cc3c22b210dae58.zip |
GET /api/tags/id_tag method
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 276cfe1c..cb68784d 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php | |||
@@ -6,7 +6,6 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc; | |||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Symfony\Component\HttpFoundation\Response; | 8 | use Symfony\Component\HttpFoundation\Response; |
9 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
10 | use Wallabag\CoreBundle\Entity\Entry; | 9 | use Wallabag\CoreBundle\Entity\Entry; |
11 | use Wallabag\CoreBundle\Entity\Tag; | 10 | use Wallabag\CoreBundle\Entity\Tag; |
12 | use Wallabag\CoreBundle\Service\Extractor; | 11 | use Wallabag\CoreBundle\Service\Extractor; |
@@ -244,12 +243,24 @@ class WallabagRestController extends Controller | |||
244 | * | 243 | * |
245 | * @ApiDoc( | 244 | * @ApiDoc( |
246 | * requirements={ | 245 | * requirements={ |
247 | * {"name"="tag", "dataType"="string", "requirement"="\w+", "description"="The tag"} | 246 | * {"name"="label", "dataType"="string", "requirement"="\w+", "description"="Label of the tag"} |
248 | * } | 247 | * } |
249 | * ) | 248 | * ) |
250 | */ | 249 | */ |
251 | public function getTagAction(Tag $tag) | 250 | public function getTagAction($label) |
252 | { | 251 | { |
252 | $tag = $this | ||
253 | ->getDoctrine() | ||
254 | ->getRepository('WallabagCoreBundle:Tag') | ||
255 | ->findOneByLabel($label); | ||
256 | |||
257 | if (is_null($tag)) { | ||
258 | throw $this->createNotFoundException(); | ||
259 | } | ||
260 | |||
261 | $json = $this->get('serializer')->serialize($tag, 'json'); | ||
262 | |||
263 | return new Response($json, 200, array('application/json')); | ||
253 | } | 264 | } |
254 | 265 | ||
255 | /** | 266 | /** |