rewrite base processing & storing route name after dispatching
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@28 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
@ -18,6 +18,7 @@ final class Router
|
|||||||
|
|
||||||
static protected $rewrite_base = '';
|
static protected $rewrite_base = '';
|
||||||
static protected $decorator = DEFAULT_DECORATOR;
|
static protected $decorator = DEFAULT_DECORATOR;
|
||||||
|
static protected $route_name = '';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,18 +56,17 @@ final class Router
|
|||||||
*/
|
*/
|
||||||
function proccess($path)
|
function proccess($path)
|
||||||
{
|
{
|
||||||
if ($trim = self::getRewriteBase()) {
|
if(self::getRewriteBase()){
|
||||||
if (substr($path, 0 , strlen($trim)) == $trim) {
|
$path = trim(ltrim($path, self::getRewriteBase()), '/');
|
||||||
$path = substr($path, strlen($trim));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = explode('/', $path);
|
$path = explode('/', $path);
|
||||||
|
|
||||||
foreach($this->routes as $name => $route) {
|
foreach($this->routes as $name => $route) {
|
||||||
if ($route->match($path)) {
|
if ($route->match($path)) {
|
||||||
$route->action .= ACTION_POSTFIX;
|
$route->action .= ACTION_POSTFIX;
|
||||||
Env::setParams($route->params);
|
Env::setParams($route->params);
|
||||||
|
self::$route_name = $name;
|
||||||
return $route;
|
return $route;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,6 +87,11 @@ final class Router
|
|||||||
{
|
{
|
||||||
self::$decorator = $decorator.DECORATOR_POSTFIX;
|
self::$decorator = $decorator.DECORATOR_POSTFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function getRouteName()
|
||||||
|
{
|
||||||
|
return self::$route_name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user