Split controllers into different files

This commit is contained in:
Vincent Jousse 2013-11-22 15:08:03 +01:00
parent e71f24ec63
commit 3734cb0090
3 changed files with 23 additions and 6 deletions

6
app/controllers/api.php Normal file
View File

@ -0,0 +1,6 @@
<?php
$api = $app['controllers_factory'];
$api->get('/', function () { return 'API home page'; });
return $api;

View File

@ -1,9 +1,7 @@
<?php
use Poche\Model\Entry;
$app->get('/', function () use ($app) {
//Default Website
$app->mount('/', include 'front.php');
$entry = new Entry(1, "Titre de test");
return $app['twig']->render('index.twig', array('entry' => $entry));
});
//Rest API
$app->mount('/api', include 'api.php');

13
app/controllers/front.php Normal file
View File

@ -0,0 +1,13 @@
<?php
use Poche\Model\Entry;
$front = $app['controllers_factory'];
$front->get('/', function () use ($app) {
$entry = new Entry(1, "Titre de test");
return $app['twig']->render('index.twig', array('entry' => $entry));
});
return $front;