Change static to dynamic method getUri.

This commit is contained in:
Alexander Demidov
2012-05-25 14:18:05 +04:00
parent 73ff07ce7d
commit 8efaf2a0a7

View File

@ -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();