mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Merge pull request #413 from WinterSilence/patch-2
Update RouteCollection::getPath
This commit is contained in:
commit
211d2d25cd
|
@ -80,18 +80,18 @@ class RouteCollection
|
|||
return $this->dataGenerator->getData();
|
||||
}
|
||||
|
||||
public function getPath($name, $parameters = [])
|
||||
protected function fixPathPart(&$part, $key, array $parameters)
|
||||
{
|
||||
$parts = $this->reverse[$name][0];
|
||||
|
||||
$path = implode('', array_map(function ($part) use ($parameters) {
|
||||
if (is_array($part)) {
|
||||
if (is_array($part) && array_key_exists($part[0], $parameters)) {
|
||||
$part = $parameters[$part[0]];
|
||||
}
|
||||
return $part;
|
||||
}, $parts));
|
||||
}
|
||||
|
||||
$path = '/' . ltrim($path, '/');
|
||||
public function getPath($name, array $parameters = [])
|
||||
{
|
||||
$parts = $this->reverse[$name][0];
|
||||
array_walk($parts, [$this, 'fixPathPart'], $parameters);
|
||||
$path = '/' . ltrim(implode('', $parts), '/');
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user