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.
コード例 #1
0
ファイル: RendererTest.php プロジェクト: EHER/monopolis
 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')))));
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: fedeisas/lithium
 protected function _saveCtrlContext()
 {
     $this->_context['scope'] = Router::scope(false);
     $this->_context['routes'] = Router::get();
     $this->_context['scopes'] = Router::attached();
     Router::reset();
 }
コード例 #3
0
ファイル: RendererTest.php プロジェクト: EHER/chegamos
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}');
     $this->subject = new Simple();
 }
コード例 #4
0
ファイル: HtmlTest.php プロジェクト: nilamdoc/KYCGlobal
 /**
  * Initialize test by creating a new object instance with a default context.
  */
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}/{:id}.{:type}');
     Router::connect('/{:controller}/{:action}.{:type}');
     $this->context = new MockRenderer(array('request' => new Request(array('base' => '', 'env' => array('HTTP_HOST' => 'foo.local'))), 'response' => new Response()));
     $this->html = new Html(array('context' => &$this->context));
 }
コード例 #5
0
ファイル: HtmlTest.php プロジェクト: EHER/chegamos
 /**
  * Initialize test by creating a new object instance with a default context.
  *
  * @return void
  */
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}/{:id}.{:type}');
     Router::connect('/{:controller}/{:action}.{:type}');
     $this->context = new MockHtmlRenderer();
     $this->html = new Html(array('context' => &$this->context));
 }
コード例 #6
0
ファイル: BackendTest.php プロジェクト: djordje/li3_backend
 /**
  * Initialize test by creating a new object instance with a default context.
  */
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/test', 'Test::index');
     Router::connect('/test2', 'TestTwo::index');
     $this->context = new MockRenderer(array('request' => new Request(array('url' => '/test', 'env' => array('HTTP_HOST' => 'foo.local'))), 'response' => new Response()));
     $this->backend = new Backend(array('context' => &$this->context));
 }
コード例 #7
0
 /**
  * Initialize test by creating a new object instance with a default context.
  *
  * @return void
  */
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::connect(null);
     Router::connect('/{:controller}/{:action}/{:id}.{:type}', array('id' => null));
     Router::connect('/{:controller}/{:action}');
     $this->context = new MockFormRenderer();
     $this->form = new Form(array('context' => $this->context));
 }
コード例 #8
0
ファイル: Route.php プロジェクト: WarToaster/HangOn
 /**
  * Lists all connected routes to the router. This is a convenience
  * alias for the `show()` method.
  *
  * Example:
  * {{{
  * li3 route
  * li3 route all
  * }}}
  *
  * Will return an output similar to:
  *
  * {{{
  * Template                        	Params
  * --------                        	------
  * /                               	{"controller":"pages","action":"view"}
  * /pages/{:args}                  	{"controller":"pages","action":"view"}
  * /{:slug:[\w\-]+}                	{"controller":"posts","action":"show"}
  * /{:controller}/{:action}/{:args}	{"action":"index"}
  * }}}
  *
  * @return void
  */
 public function all()
 {
     $routes = Router::get();
     $columns = array(array('Template', 'Params'), array('--------', '------'));
     foreach ($routes as $route) {
         $info = $route->export();
         $columns[] = array($info['template'], json_encode($info['params']));
     }
     $this->columns($columns);
 }
コード例 #9
0
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}/page/{:page:[0-9]+}');
     $request = new Request();
     $request->params = array('controller' => 'posts', 'action' => 'index');
     $request->persist = array('controller');
     $this->context = new MockRenderer(compact('request'));
     $this->pagination = new Pagination(array('context' => $this->context));
 }
コード例 #10
0
 /**
  * Initialize test by creating a new object instance with a default context.
  */
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}/{:id}.{:type}', array('id' => null));
     Router::connect('/{:controller}/{:action}/{:args}');
     $request = new Request();
     $request->params = array('controller' => 'posts', 'action' => 'index');
     $request->persist = array('controller');
     $this->context = new MockFormRenderer(compact('request'));
     $this->form = new Form(array('context' => $this->context));
     $this->base = $this->context->request()->env('base') . '/';
 }
コード例 #11
0
 function setup()
 {
     // Route
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}/{:id}.{:type}');
     Router::connect('/{:controller}/{:action}.{:type}');
     // Info
     $this->account = sprintf('UA-%05d-X', rand(1, 99999));
     // Tracking
     Trackers::add('test', array('account' => $this->account, 'adapter' => 'GoogleAnalytics'));
     // Context
     $this->context = new MockHtmlRenderer(array('request' => new Request(array('base' => '', 'env' => array('HTTP_HOST' => 'foo.local'))), 'response' => new Response()));
     // Analytics
     $this->analytics = new Analytics(array('context' => &$this->context));
 }
コード例 #12
0
ファイル: RouteTest.php プロジェクト: unionofrad/lithium
 /**
  * Test if the routes.php file is loaded correctly and the
  * routes are connected to the router.
  */
 public function testRouteLoading()
 {
     $this->assertEmpty(Router::get(null, true));
     $command = new Route(array('routes' => $this->_config['routes']));
     $this->assertCount(4, Router::get(null, true));
     Router::reset();
     $request = new Request();
     $request->params['env'] = 'production';
     $command = new Route(compact('request') + array('routes' => $this->_config['routes']));
     $this->assertCount(2, Router::get(null, true));
 }
コード例 #13
0
 /**
  * Test if the routes.php file is loaded correctly and the
  * routes are connected to the router.
  */
 public function testRouteLoading()
 {
     $this->assertFalse(Router::get());
     $command = new Route(array('routes' => $this->_config['routes']));
     $this->assertEqual(4, count(Router::get()));
     Router::reset();
     $request = new Request();
     $request->params['env'] = 'production';
     $command = new Route(compact('request') + array('routes' => $this->_config['routes']));
     $this->assertEqual(2, count(Router::get()));
 }
コード例 #14
0
ファイル: DispatcherTest.php プロジェクト: nashadalam/lithium
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
 }
コード例 #15
0
ファイル: FileTest.php プロジェクト: globus40000/li3_mailer
 public function setDefaultRoute()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}');
 }
コード例 #16
0
 public function setUp()
 {
     $this->_routes = Router::get();
     Router::connect(null);
 }
コード例 #17
0
 /**
  * Tests getting routes using `Router::get()`, and checking to see if the routes returned match
  * the routes connected.
  */
 public function testRouteRetrieval()
 {
     $expected = Router::connect('/hello', array('controller' => 'posts', 'action' => 'index'));
     $result = Router::get(0);
     $this->assertIdentical($expected, $result);
     list($result) = Router::get();
     $this->assertIdentical($expected, $result);
 }
コード例 #18
0
ファイル: RouterTest.php プロジェクト: unionofrad/lithium
 public function testRouteRetrievalWithScope()
 {
     Router::scope('loc1', function () use(&$expected) {
         $expected = Router::connect('/hello', array('controller' => 'Posts', 'action' => 'index'));
     });
     $result = Router::get(0, true);
     $this->assertIdentical(null, $result);
     $result = Router::get(0, 'loc1');
     $this->assertIdentical($expected, $result);
     Router::scope('loc1', function () {
         Router::connect('/helloworld', array('controller' => 'Posts', 'action' => 'index'));
     });
     Router::scope('loc2', function () {
         Router::connect('/hello', array('controller' => 'Posts', 'action' => 'index'));
     });
     $this->assertCount(0, Router::get(null, true));
     $result = count(Router::get(null, 'loc1'));
     $this->assertCount(2, Router::get(null, 'loc1'));
     $scopes = Router::get();
     $result = 0;
     foreach ($scopes as $routes) {
         $result += count($routes);
     }
     $this->assertIdentical(3, $result);
 }