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:
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user