Update FastRoute

This enables optional route parameters.

Required some code changes in the RouteCollection class; once we
actually use optional route parameters, we will have to see whether
route generation for those works as expected.

Closes flarum/core#108
This commit is contained in:
Franz Liedke 2015-06-26 23:09:58 +02:00
parent cca97398ae
commit 150b8d7cd3
3 changed files with 11 additions and 11 deletions

View File

@ -18,7 +18,7 @@
"ezyang/htmlpurifier": "dev-master", "ezyang/htmlpurifier": "dev-master",
"psr/http-message": "^1.0@dev", "psr/http-message": "^1.0@dev",
"zendframework/zend-diactoros": "^1.1", "zendframework/zend-diactoros": "^1.1",
"nikic/fast-route": "dev-master", "nikic/fast-route": "^0.6",
"dflydev/fig-cookies": "^1.0" "dflydev/fig-cookies": "^1.0"
}, },
"require-dev": { "require-dev": {

View File

@ -581,12 +581,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/FastRoute.git", "url": "https://github.com/nikic/FastRoute.git",
"reference": "ffb3b68a3ab0df7e60cf587d2de4937915670f16" "reference": "31fa86924556b80735f98b294a7ffdfb26789f22"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/31fa86924556b80735f98b294a7ffdfb26789f22", "url": "https://api.github.com/repos/nikic/FastRoute/zipball/31fa86924556b80735f98b294a7ffdfb26789f22",
"reference": "ffb3b68a3ab0df7e60cf587d2de4937915670f16", "reference": "31fa86924556b80735f98b294a7ffdfb26789f22",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -616,7 +616,7 @@
"router", "router",
"routing" "routing"
], ],
"time": "2015-05-15 16:58:32" "time": "2015-06-18 19:15:47"
}, },
{ {
"name": "oyejorge/less.php", "name": "oyejorge/less.php",

View File

@ -50,13 +50,13 @@ class RouteCollection
public function addRoute($method, $path, $name, $handler) public function addRoute($method, $path, $name, $handler)
{ {
$this->dataGenerator->addRoute( $routeDatas = $this->routeParser->parse($path);
$method,
$parsed = $this->routeParser->parse($path),
$handler
);
$this->reverse[$name] = $parsed; foreach ($routeDatas as $routeData) {
$this->dataGenerator->addRoute($method, $routeData, $handler);
}
$this->reverse[$name] = $routeDatas;
return $this; return $this;
} }
@ -68,7 +68,7 @@ class RouteCollection
public function getPath($name, $parameters = []) public function getPath($name, $parameters = [])
{ {
$parts = $this->reverse[$name]; $parts = $this->reverse[$name][0];
$path = implode('', array_map(function ($part) use ($parameters) { $path = implode('', array_map(function ($part) use ($parameters) {
if (is_array($part)) { if (is_array($part)) {