|
|
@ -5,15 +5,18 @@ |
|
|
|
* @package Majestic |
|
|
|
* @subpackage app |
|
|
|
* @since 2010-02-25 |
|
|
|
* @version SVN: $Id$ |
|
|
|
* @filesource $URL$ |
|
|
|
*/ |
|
|
|
|
|
|
|
class Router |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @var Route[] |
|
|
|
*/ |
|
|
|
protected $routes = array(); |
|
|
|
|
|
|
|
/** |
|
|
|
* @var string |
|
|
|
*/ |
|
|
|
protected $route_name; |
|
|
|
|
|
|
|
protected $default_layout = 'Default'; |
|
|
@ -33,6 +36,10 @@ class Router |
|
|
|
$this->routes[$name] = new Route($route, $action, $params, $layout); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param $request |
|
|
|
* @return bool|Route |
|
|
|
*/ |
|
|
|
public function route($request) |
|
|
|
{ |
|
|
|
$req = explode('/', trim($request, '/')); |
|
|
@ -48,6 +55,10 @@ class Router |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Set default layout name |
|
|
|
* @param string $layout |
|
|
|
*/ |
|
|
|
public function setDefaultLayout($layout = 'Default') |
|
|
|
{ |
|
|
|
$this->default_layout = $layout; |
|
|
@ -71,6 +82,10 @@ class Router |
|
|
|
return $this->error_layout . 'Layout'; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Return current router name |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
public function getRouteName() |
|
|
|
{ |
|
|
|
return $this->route_name; |
|
|
|