mirror of
https://github.com/moparisthebest/wallabag
synced 2024-12-18 05:32:23 -05:00
Add EntryApi as a Service
This commit is contained in:
parent
3734cb0090
commit
6dc90c704c
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use Knp\Provider\ConsoleServiceProvider;
|
||||
use Poche\Api\EntryApi;
|
||||
|
||||
$app = new Silex\Application();
|
||||
|
||||
@ -19,3 +20,7 @@ $app->register(new Silex\Provider\DoctrineServiceProvider(), array(
|
||||
'path' => __DIR__.'/../poche.db',
|
||||
),
|
||||
));
|
||||
|
||||
$app['entry_api'] = $app->share(function ($app) {
|
||||
return new EntryApi($app['db']);
|
||||
});
|
||||
|
@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
|
||||
$api = $app['controllers_factory'];
|
||||
$api->get('/', function () { return 'API home page'; });
|
||||
|
||||
$api->get('/entries', function () use ($app) {
|
||||
$entries = $app['entry_api']->getEntries();
|
||||
return json_encode($entries);
|
||||
});
|
||||
|
||||
return $api;
|
||||
|
17
src/Poche/Api/EntryApi.php
Normal file
17
src/Poche/Api/EntryApi.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Poche\Api;
|
||||
|
||||
class EntryApi
|
||||
{
|
||||
private $db;
|
||||
|
||||
public function __construct($db) {
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
public function getEntries() {
|
||||
//Todo
|
||||
return array();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user