Created
March 4, 2015 21:08
-
-
Save jaytaph/4499b3f23c59a312f467 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Application; | |
class Controller { | |
protected $app; | |
function __construct($app) { | |
$this->app = $app; | |
} | |
function getListAction() { | |
// Doe je ding voor getList | |
} | |
function getContactAction() { | |
// doe je ding voor getContact | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$app = new Silex\Application(); | |
// Doe hier je standaard silex setup | |
// application.controller service wijst naar je controller class met je acties | |
$app['application.controller'] = $app->share(function() use ($app) { | |
return new \Application\Controller($app); | |
} | |
// Dit kan een controller met acties zijn voor een gastenboek bijvoorbeeld | |
$app['guestbook.controller'] = $app->share(function() use ($app) { | |
// GuestbookController in dezelfde trant als the Controller.php | |
return new \Application\GuestbookController($app); | |
} | |
// get '/' wijst naar de getListAction uit de 'application.controller' service en gebonden aan 'home' | |
$app->get('/', 'application.controller:getListAction')->bind('home'); | |
// get '/contact' wijst naar de getContactAction uit de 'application.controller' service en gebonden aan 'contact' | |
$app->get('/contact', 'application.controller:getContactAction')->bind('contact'); | |
// get '/gastenboek' wijst naar de getIndexAction uit de 'guestbook.controller' | |
$app->get('/guestbook', 'guestbook.getIndexAction')->bind('guestbook'); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment