]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
bundle for API
authorNicolas Lœuillet <nicolas@loeuillet.org>
Wed, 28 Jan 2015 17:14:04 +0000 (18:14 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Wed, 28 Jan 2015 17:14:04 +0000 (18:14 +0100)
app/AppKernel.php
app/config/routing.yml
app/config/routing_rest.yml [deleted file]
src/Wallabag/ApiBundle/Controller/EntryController.php [new file with mode: 0644]
src/Wallabag/ApiBundle/WallabagApiBundle.php [new file with mode: 0644]
src/Wallabag/CoreBundle/Controller/ApiController.php [deleted file]

index e2db75a7206c220abf6a9a44a22da16d0d08de19..e8160135ebcf3012a25326fc35d9a288385e39aa 100644 (file)
@@ -2,6 +2,7 @@
 
 use Symfony\Component\HttpKernel\Kernel;
 use Symfony\Component\Config\Loader\LoaderInterface;
+use Wallabag\ApiBundle\WallabagApiBundle;
 
 class AppKernel extends Kernel
 {
@@ -20,6 +21,7 @@ class AppKernel extends Kernel
             new JMS\SerializerBundle\JMSSerializerBundle(),
             new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
             new Wallabag\CoreBundle\WallabagCoreBundle(),
+            new Wallabag\ApiBundle\WallabagApiBundle(),
         );
 
         if (in_array($this->getEnvironment(), array('dev', 'test'))) {
index a57311dc09dc395001435bcf1d125c6b3609904c..60fcb6f4b8c4969bdb533b8c36d45189e41bb9ed 100644 (file)
@@ -10,7 +10,7 @@ doc-api:
     resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
     prefix: /api/doc
 
-rest :
-    type : rest
-    resource : "routing_rest.yml"
-    prefix : /api
\ No newline at end of file
+wallabag_api:
+    resource: "@WallabagApiBundle/Controller/"
+    type:     annotation
+    prefix:   /api
\ No newline at end of file
diff --git a/app/config/routing_rest.yml b/app/config/routing_rest.yml
deleted file mode 100644 (file)
index ecddbd3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-app_api :
-    type: rest
-    resource:     "WallabagCoreBundle:Api"
-    name_prefix:  api_
\ No newline at end of file
diff --git a/src/Wallabag/ApiBundle/Controller/EntryController.php b/src/Wallabag/ApiBundle/Controller/EntryController.php
new file mode 100644 (file)
index 0000000..07ca8cc
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace Wallabag\ApiBundle\Controller;
+
+use Nelmio\ApiDocBundle\Annotation\ApiDoc;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Wallabag\CoreBundle\Entity\Entries;
+use FOS\RestBundle\Controller\Annotations\Get;
+use Wallabag\CoreBundle\Entity\Users;
+
+class EntryController extends Controller
+{
+    /**
+     * Fetch an entry for a given user
+     *
+     * @Get("/u/{user}/entry/{entry}")
+     * @ApiDoc(
+     *      requirements={
+     *          {"name"="user", "dataType"="string", "requirement"="\w+", "description"="The username"},
+     *          {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
+     *      }
+     * )
+     * @return Entries
+     */
+    public function getAction(Users $user, Entries $entry)
+    {
+        return $entry;
+    }
+}
diff --git a/src/Wallabag/ApiBundle/WallabagApiBundle.php b/src/Wallabag/ApiBundle/WallabagApiBundle.php
new file mode 100644 (file)
index 0000000..19d887a
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+namespace Wallabag\ApiBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class WallabagApiBundle extends Bundle
+{
+}
diff --git a/src/Wallabag/CoreBundle/Controller/ApiController.php b/src/Wallabag/CoreBundle/Controller/ApiController.php
deleted file mode 100644 (file)
index ac06701..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-
-namespace Wallabag\CoreBundle\Controller;
-
-use Nelmio\ApiDocBundle\Annotation\ApiDoc;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Wallabag\CoreBundle\Entity\Entries;
-
-class ApiController extends Controller
-{
-    /**
-     * @ApiDoc(
-     *  resource=true,
-     *  description="This is a demo method. Just remove it",
-     * )
-     */
-    public function getEntryAction()
-    {
-        return new Entries('Blobby');
-    }
-}