Flarum\Http\RouteCollection::getPath PHP 메소드

getPath() 공개 메소드

public getPath ( $name, array $parameters = [] )
$parameters array
    public function getPath($name, array $parameters = [])
    {
        if (isset($this->reverse[$name])) {
            $parts = $this->reverse[$name][0];
            array_walk($parts, [$this, 'fixPathPart'], $parameters);
            return '/' . ltrim(implode('', $parts), '/');
        }
        throw new \RuntimeException("Route {$name} not found");
    }

Usage Example

예제 #1
0
 /**
  * Generate a URL to a named route.
  *
  * @param string $name
  * @param array $parameters
  * @return string
  */
 public function toRoute($name, $parameters = [])
 {
     $path = $this->routes->getPath($name, $parameters);
     $path = ltrim($path, '/');
     return $this->toBase() . '/' . $path;
 }