lithium\net\http\Router::get PHP Method

get() public static method

A specific route can be retrived by providing its index. All connected routes inside all scopes may be retrieved by providing null instead of the route index. To retrieve all routes for the current scope only, pass true for the $scope parameter.
public static get ( integer $route = null, string | boolean $scope = null ) : object | array | null
$route integer Index of the route.
$scope string | boolean Name of the scope to get routes from. Uses default scope if `true`.
return object | array | null If $route is an integer, returns the route object at given index or if that fails returns `null`. If $route is `null` returns an array of routes or scopes with their respective routes depending on the value of $scope.
    public static function get($route = null, $scope = null)
    {
        if ($route === null && $scope === null) {
            return static::$_configurations;
        }
        if ($scope === true) {
            $scope = static::$_scope;
        }
        if ($route === null && $scope !== null) {
            if (isset(static::$_configurations[$scope])) {
                return static::$_configurations[$scope];
            }
            return array();
        }
        if (!isset(static::$_configurations[$scope][$route])) {
            return null;
        }
        return static::$_configurations[$scope][$route];
    }

Usage Example

Example #1
0
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}');
     $this->subject = new Simple(array('request' => new Request(array('base' => '', 'env' => array('HTTP_HOST' => 'foo.local')))));
 }
All Usage Examples Of lithium\net\http\Router::get