mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
bundle for API
This commit is contained in:
parent
e4788de51e
commit
3e5a342f65
6 changed files with 44 additions and 29 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
use Wallabag\ApiBundle\WallabagApiBundle;
|
||||||
|
|
||||||
class AppKernel extends Kernel
|
class AppKernel extends Kernel
|
||||||
{
|
{
|
||||||
|
@ -20,6 +21,7 @@ class AppKernel extends Kernel
|
||||||
new JMS\SerializerBundle\JMSSerializerBundle(),
|
new JMS\SerializerBundle\JMSSerializerBundle(),
|
||||||
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
|
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
|
||||||
new Wallabag\CoreBundle\WallabagCoreBundle(),
|
new Wallabag\CoreBundle\WallabagCoreBundle(),
|
||||||
|
new Wallabag\ApiBundle\WallabagApiBundle(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
|
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ doc-api:
|
||||||
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
|
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
|
||||||
prefix: /api/doc
|
prefix: /api/doc
|
||||||
|
|
||||||
rest :
|
wallabag_api:
|
||||||
type : rest
|
resource: "@WallabagApiBundle/Controller/"
|
||||||
resource : "routing_rest.yml"
|
type: annotation
|
||||||
prefix : /api
|
prefix: /api
|
|
@ -1,4 +0,0 @@
|
||||||
app_api :
|
|
||||||
type: rest
|
|
||||||
resource: "WallabagCoreBundle:Api"
|
|
||||||
name_prefix: api_
|
|
29
src/Wallabag/ApiBundle/Controller/EntryController.php
Normal file
29
src/Wallabag/ApiBundle/Controller/EntryController.php
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
9
src/Wallabag/ApiBundle/WallabagApiBundle.php
Normal file
9
src/Wallabag/ApiBundle/WallabagApiBundle.php
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Wallabag\ApiBundle;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
|
|
||||||
|
class WallabagApiBundle extends Bundle
|
||||||
|
{
|
||||||
|
}
|
|
@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue