From 150b8d7cd32f4bee20965b5afc5b64c9624d34db Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 26 Jun 2015 23:09:58 +0200 Subject: [PATCH] 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 --- framework/core/composer.json | 2 +- framework/core/composer.lock | 6 +++--- framework/core/src/Http/RouteCollection.php | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/framework/core/composer.json b/framework/core/composer.json index 92e74a4a0..6af569ce6 100644 --- a/framework/core/composer.json +++ b/framework/core/composer.json @@ -18,7 +18,7 @@ "ezyang/htmlpurifier": "dev-master", "psr/http-message": "^1.0@dev", "zendframework/zend-diactoros": "^1.1", - "nikic/fast-route": "dev-master", + "nikic/fast-route": "^0.6", "dflydev/fig-cookies": "^1.0" }, "require-dev": { diff --git a/framework/core/composer.lock b/framework/core/composer.lock index 4f3bba92f..07fd1d2d5 100644 --- a/framework/core/composer.lock +++ b/framework/core/composer.lock @@ -581,12 +581,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/FastRoute.git", - "reference": "ffb3b68a3ab0df7e60cf587d2de4937915670f16" + "reference": "31fa86924556b80735f98b294a7ffdfb26789f22" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/nikic/FastRoute/zipball/31fa86924556b80735f98b294a7ffdfb26789f22", - "reference": "ffb3b68a3ab0df7e60cf587d2de4937915670f16", + "reference": "31fa86924556b80735f98b294a7ffdfb26789f22", "shasum": "" }, "require": { @@ -616,7 +616,7 @@ "router", "routing" ], - "time": "2015-05-15 16:58:32" + "time": "2015-06-18 19:15:47" }, { "name": "oyejorge/less.php", diff --git a/framework/core/src/Http/RouteCollection.php b/framework/core/src/Http/RouteCollection.php index ecfe9c635..825033fe5 100644 --- a/framework/core/src/Http/RouteCollection.php +++ b/framework/core/src/Http/RouteCollection.php @@ -50,13 +50,13 @@ class RouteCollection public function addRoute($method, $path, $name, $handler) { - $this->dataGenerator->addRoute( - $method, - $parsed = $this->routeParser->parse($path), - $handler - ); + $routeDatas = $this->routeParser->parse($path); - $this->reverse[$name] = $parsed; + foreach ($routeDatas as $routeData) { + $this->dataGenerator->addRoute($method, $routeData, $handler); + } + + $this->reverse[$name] = $routeDatas; return $this; } @@ -68,7 +68,7 @@ class RouteCollection public function getPath($name, $parameters = []) { - $parts = $this->reverse[$name]; + $parts = $this->reverse[$name][0]; $path = implode('', array_map(function ($part) use ($parameters) { if (is_array($part)) {