Commit d3810642 authored by Igor Wiedler's avatar Igor Wiedler

update to the new routing syntax

parent 82a57978
......@@ -8,11 +8,11 @@ Silex is a simple web framework to develop simple websites:
$app = Framework::create();
$app->get('/home/:name', function($name) {
$app->get('/home/{name}', function($name) {
return "Hello $name";
});
$app->match('/goodbye/:name', function($name) {
$app->match('/goodbye/{name}', function($name) {
return "Goodbye $name";
});
......
......@@ -79,8 +79,11 @@ class Framework extends HttpKernel
$requirements['_method'] = $method;
}
$routeName = (string) $method . $pattern;
$routeName = str_replace(array('{', '}'), '', $routeName);
$routeName = str_replace(array('/', ':', '|'), '_', $routeName);
$route = new Route($pattern, array('_controller' => $to), $requirements);
$this->routes->add(str_replace(array('/', ':', '|'), '_', (string) $method . $pattern), $route);
$this->routes->add($routeName, $route);
return $this;
}
......
Subproject commit 183acd8460e048d8bbd1aae56e58846712014505
Subproject commit 36d87d94648e11b52ad55f82ec781aa01bd16ca9
......@@ -93,13 +93,13 @@ class RouterTest extends \PHPUnit_Framework_TestCase
'/hello' => function() {
return "Hello anon";
},
'/hello/:name' => function($name) {
'/hello/{name}' => function($name) {
return "Hello $name";
},
'/goodbye/:name' => function($name) {
'/goodbye/{name}' => function($name) {
return "Goodbye $name";
},
'/tell/:name/:message' => function($message, $name) {
'/tell/{name}/{message}' => function($message, $name) {
return "Message for $name: $message";
},
'/' => function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment