diff options
-rw-r--r-- | app/AppKernel.php | 2 | ||||
-rw-r--r-- | app/config/routing.yml | 8 | ||||
-rw-r--r-- | app/config/routing_rest.yml | 4 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/EntryController.php | 29 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/WallabagApiBundle.php | 9 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ApiController.php | 21 |
6 files changed, 44 insertions, 29 deletions
diff --git a/app/AppKernel.php b/app/AppKernel.php index e2db75a7..e8160135 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | use Symfony\Component\HttpKernel\Kernel; | 3 | use Symfony\Component\HttpKernel\Kernel; |
4 | use Symfony\Component\Config\Loader\LoaderInterface; | 4 | use Symfony\Component\Config\Loader\LoaderInterface; |
5 | use Wallabag\ApiBundle\WallabagApiBundle; | ||
5 | 6 | ||
6 | class AppKernel extends Kernel | 7 | class AppKernel extends Kernel |
7 | { | 8 | { |
@@ -20,6 +21,7 @@ class AppKernel extends Kernel | |||
20 | new JMS\SerializerBundle\JMSSerializerBundle(), | 21 | new JMS\SerializerBundle\JMSSerializerBundle(), |
21 | new Nelmio\ApiDocBundle\NelmioApiDocBundle(), | 22 | new Nelmio\ApiDocBundle\NelmioApiDocBundle(), |
22 | new Wallabag\CoreBundle\WallabagCoreBundle(), | 23 | new Wallabag\CoreBundle\WallabagCoreBundle(), |
24 | new Wallabag\ApiBundle\WallabagApiBundle(), | ||
23 | ); | 25 | ); |
24 | 26 | ||
25 | if (in_array($this->getEnvironment(), array('dev', 'test'))) { | 27 | if (in_array($this->getEnvironment(), array('dev', 'test'))) { |
diff --git a/app/config/routing.yml b/app/config/routing.yml index a57311dc..60fcb6f4 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml | |||
@@ -10,7 +10,7 @@ doc-api: | |||
10 | resource: "@NelmioApiDocBundle/Resources/config/routing.yml" | 10 | resource: "@NelmioApiDocBundle/Resources/config/routing.yml" |
11 | prefix: /api/doc | 11 | prefix: /api/doc |
12 | 12 | ||
13 | rest : | 13 | wallabag_api: |
14 | type : rest | 14 | resource: "@WallabagApiBundle/Controller/" |
15 | resource : "routing_rest.yml" | 15 | type: annotation |
16 | prefix : /api \ No newline at end of file | 16 | 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 index ecddbd36..00000000 --- a/app/config/routing_rest.yml +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | app_api : | ||
2 | type: rest | ||
3 | resource: "WallabagCoreBundle:Api" | ||
4 | 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 index 00000000..07ca8ccf --- /dev/null +++ b/src/Wallabag/ApiBundle/Controller/EntryController.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ApiBundle\Controller; | ||
4 | |||
5 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | ||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Wallabag\CoreBundle\Entity\Entries; | ||
8 | use FOS\RestBundle\Controller\Annotations\Get; | ||
9 | use Wallabag\CoreBundle\Entity\Users; | ||
10 | |||
11 | class EntryController extends Controller | ||
12 | { | ||
13 | /** | ||
14 | * Fetch an entry for a given user | ||
15 | * | ||
16 | * @Get("/u/{user}/entry/{entry}") | ||
17 | * @ApiDoc( | ||
18 | * requirements={ | ||
19 | * {"name"="user", "dataType"="string", "requirement"="\w+", "description"="The username"}, | ||
20 | * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} | ||
21 | * } | ||
22 | * ) | ||
23 | * @return Entries | ||
24 | */ | ||
25 | public function getAction(Users $user, Entries $entry) | ||
26 | { | ||
27 | return $entry; | ||
28 | } | ||
29 | } | ||
diff --git a/src/Wallabag/ApiBundle/WallabagApiBundle.php b/src/Wallabag/ApiBundle/WallabagApiBundle.php new file mode 100644 index 00000000..19d887ab --- /dev/null +++ b/src/Wallabag/ApiBundle/WallabagApiBundle.php | |||
@@ -0,0 +1,9 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ApiBundle; | ||
4 | |||
5 | use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
6 | |||
7 | class WallabagApiBundle extends Bundle | ||
8 | { | ||
9 | } | ||
diff --git a/src/Wallabag/CoreBundle/Controller/ApiController.php b/src/Wallabag/CoreBundle/Controller/ApiController.php deleted file mode 100644 index ac06701c..00000000 --- a/src/Wallabag/CoreBundle/Controller/ApiController.php +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Controller; | ||
4 | |||
5 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | ||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Wallabag\CoreBundle\Entity\Entries; | ||
8 | |||
9 | class ApiController extends Controller | ||
10 | { | ||
11 | /** | ||
12 | * @ApiDoc( | ||
13 | * resource=true, | ||
14 | * description="This is a demo method. Just remove it", | ||
15 | * ) | ||
16 | */ | ||
17 | public function getEntryAction() | ||
18 | { | ||
19 | return new Entries('Blobby'); | ||
20 | } | ||
21 | } | ||