requestRoute() public static method

Returns the route matching the current request URL.
public static requestRoute ( ) : CakeRoute
return CakeRoute Matching route object.
Example #1
0
 /**
  * testRequestRoute
  *
  * @return void
  * @access public
  */
 function testRequestRoute()
 {
     $url = array('controller' => 'products', 'action' => 'display', 5);
     Router::connect('/government', $url);
     Router::parse('/government');
     $route = Router::requestRoute();
     $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]);
     // test that the first route is matched
     $newUrl = array('controller' => 'products', 'action' => 'display', 6);
     Router::connect('/government', $url);
     Router::parse('/government');
     $route = Router::requestRoute();
     $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]);
     // test that an unmatched route does not change the current route
     $newUrl = array('controller' => 'products', 'action' => 'display', 6);
     Router::connect('/actor', $url);
     Router::parse('/government');
     $route = Router::requestRoute();
     $this->assertEqual(array_merge($url, array('plugin' => false)), $route[3]);
 }