1
0
mirror of https://github.com/flarum/core.git synced 2025-07-26 11:10:41 +02:00

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

@@ -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)) {