/** * Test loading a namespace * * @param string $namespace the namespace to test * @param array $uris an array of uris to test * * @dataProvider provider_parameter * * @return null */ public function test_parameter($namespace, $uris) { Route::load_namespace($namespace); foreach ($uris as $uri => $checks) { $request = Request::factory($uri); foreach ($checks as $parameter => $expected) { $this->assertSame($expected, $request->param($parameter)); } } Route::clear_namespace($namespace); }
/** * Retrieves a named route optionally by a namespace. * * $route = Route::get('default', 'www'); * * @param string $name route name * @param string $namespace the namespace to fetch from * * @return Route * @throws Kohana_Exception */ public static function get($name, $namespace = null) { // make sure the namespace is loaded if (null !== $namespace and !isset(Route::$_routes[$namespace])) { Route::load_namespace($namespace); } if (null !== $namespace ? !isset(Route::$_routes[$namespace][$name]) : !isset(Route::$_routes[$name])) { throw new Kohana_Exception('The requested route does not exist: :route', array(':route' => $name)); } return $namespace !== null ? Route::$_routes[$namespace][$name] : Route::$_routes[$name]; }