Example #1
0
 /**
  * Get path for a validated route.
  *
  * @param \Jivoo\Http\Route\Route $route Validated route.
  * @return string[]|string Path array or absolute path string.
  * @throws Route\RouteException If the a path could not be found for
  * the route.
  */
 public function getPathValidated(Route\Route $route)
 {
     $parameters = $route->getParameters();
     if (count($parameters)) {
         $arity = '[' . count($parameters) . ']';
     } else {
         $arity = '[0]';
     }
     $key = $route->withoutAttributes()->__toString();
     $pattern = null;
     if (isset($this->paths[$key . $arity])) {
         $pattern = $this->paths[$key . $arity]['pattern'];
     } elseif (isset($this->paths[$key . '[*]'])) {
         $pattern = $this->paths[$key . '[*]']['pattern'];
     }
     $path = $route->getPath($pattern);
     if (!isset($path)) {
         throw new Route\RouteException('Could not find path for: ' . $key . $arity);
     }
     return $path;
 }