Change static to dynamic method getUri.
This commit is contained in:
@ -64,27 +64,26 @@ class Router
|
|||||||
return $this->route;
|
return $this->route;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function routeIsExists($name)
|
protected function routeIsExists($name)
|
||||||
{
|
{
|
||||||
return array_key_exists($name, $this->routes);
|
return array_key_exists($name, $this->routes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRouteByName($name)
|
protected function getRouteByName($name)
|
||||||
{
|
{
|
||||||
return $this->routes[$name];
|
return $this->routes[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getUri($route_name = null)
|
public function getUri($route_name = null)
|
||||||
{
|
{
|
||||||
$router = FrontController::getInstance()->getRouter();
|
|
||||||
if (is_null($route_name)) {
|
if (is_null($route_name)) {
|
||||||
$route = $router->getRoute();
|
$route = $this->getRoute();
|
||||||
} else {
|
} else {
|
||||||
if ($router->routeIsExists($route_name)) {
|
if ($this->routeIsExists($route_name)) {
|
||||||
$route = $router->getRouteByName($route_name);
|
$route = $this->getRouteByName($route_name);
|
||||||
} else {
|
} else {
|
||||||
$btrace = debug_backtrace();
|
$btrace = debug_backtrace();
|
||||||
throw new ErrorException('Unknown route handler: "' . $route_name . '". ' . 'Call from "' . $btrace[0]['file'] . '" on line ' . $btrace[0]['line'] . '.');
|
throw new ErrorException('Unknown route name: "' . $route_name . '". ' . 'Call from "' . $btrace[0]['file'] . '" on line ' . $btrace[0]['line'] . '.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $route->getUri();
|
return $route->getUri();
|
||||||
|
Reference in New Issue
Block a user