예제 #1
0
 function testActionRoute()
 {
     $routes = new RouteCollection();
     $route = new Route('/foo', 'foo@bar');
     $routes->add($route, 'foo');
     $this->assertEquals($route, $routes->getByAction('foo@bar'));
 }
예제 #2
0
파일: Router.php 프로젝트: slince/routing
 /**
  * 根据action生成url
  * @param $action
  * @param array $parameters
  * @param bool $absolute
  * @return string
  * @throws RouteNotFoundException
  */
 function generateByAction($action, $parameters = [], $absolute = false)
 {
     $route = $this->routes->getByAction($action);
     if (is_null($route)) {
         throw new RouteNotFoundException(sprintf('Action "%s" not defined.', $action));
     }
     return $this->getGenerator()->generate($route, $parameters, $absolute);
 }