controllers.php 797 B

123456789101112131415161718192021222324252627
  1. <?php
  2. use Symfony\Component\HttpFoundation\Request;
  3. use Symfony\Component\HttpFoundation\Response;
  4. //Request::setTrustedProxies(array('127.0.0.1'));
  5. $app->get('/', function () use ($app) {
  6. return $app['twig']->render('index.html.twig', array());
  7. })
  8. ->bind('homepage');
  9. $app->error(function (\Exception $e, Request $request, $code) use ($app) {
  10. if ($app['debug']) {
  11. return;
  12. }
  13. // 404.html, or 40x.html, or 4xx.html, or error.html
  14. $templates = array(
  15. 'errors/' . $code . '.html.twig',
  16. 'errors/' . substr($code, 0, 2) . 'x.html.twig',
  17. 'errors/' . substr($code, 0, 1) . 'xx.html.twig',
  18. 'errors/default.html.twig',
  19. );
  20. return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code);
  21. });