Cleanup controllers

This commit is contained in:
Romain Neutron
2012-09-28 12:57:11 +02:00
parent 697b234d54
commit f68cae2bb4
21 changed files with 2114 additions and 2154 deletions

View File

@@ -28,20 +28,20 @@ class MustacheLoader implements ControllerProviderInterface
$controllers = $app['controllers_factory'];
$controllers->get('/', function(Application $app, Request $request) {
$template_name = $request->query->get('template');
$template_name = $request->query->get('template');
if ( ! preg_match('/^[a-zA-Z0-9-_]+$/', $template_name)) {
throw new \Exception_BadRequest('Wrong template name : ' . $template_name);
}
if (!preg_match('/^[a-zA-Z0-9-_]+$/', $template_name)) {
throw new \Exception_BadRequest('Wrong template name : ' . $template_name);
}
$template_path = realpath(__DIR__ . '/../../../../../templates/web/Mustache/Prod/' . $template_name . '.Mustache.html');
$template_path = realpath(__DIR__ . '/../../../../../templates/web/Mustache/Prod/' . $template_name . '.Mustache.html');
if ( ! file_exists($template_path)) {
throw new \Exception_NotFound('Template does not exists : ' . $template_path);
}
if (!file_exists($template_path)) {
throw new \Exception_NotFound('Template does not exists : ' . $template_path);
}
return new \Symfony\Component\HttpFoundation\Response(file_get_contents($template_path));
});
return new \Symfony\Component\HttpFoundation\Response(file_get_contents($template_path));
});
return $controllers;
}