Skip to content

Instantly share code, notes, and snippets.

@dominikzogg
Last active December 31, 2015 13:08
Show Gist options
  • Save dominikzogg/7990454 to your computer and use it in GitHub Desktop.
Save dominikzogg/7990454 to your computer and use it in GitHub Desktop.
<?php
class BlogController
{
/**
* @var \Twig_Environment
*/
protected $twig;
/**
* @var Twig_Environment
*/
public function __construct(\Twig_Environment $twig)
{
$this->twig = $twig;
}
/**
* @param Request $request
*/
public function listAction(Request $request)
{
return $this->twig->render....
}
/**
* @param Request $request
* @param integer $id
*/
public function viewAction(Request $request, $id)
{
return $this->twig->render....
}
}
$app['blog.controller'] = $app->share(function() use ($app) {
return new BlogController($app['twig']);
});
$blogActions = $app['controllers_factory'];
$blogActions->get('/', 'blog.controller:listAction');
$blogActions->get('/{id}', 'blog.controller:viewAction');
$app->mount('/{_locale}/blog', $blogActions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment