Browse Source

Change static to dynamic method getUri.

master
Alexander Demidov 13 years ago
parent
commit
8efaf2a0a7
  1. 15
      app/router/Router.php

15
app/router/Router.php

@ -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)) {
$route = $router->getRouteByName($route_name);
if ($this->routeIsExists($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();

Loading…
Cancel
Save