function testActionRoute() { $routes = new RouteCollection(); $route = new Route('/foo', 'foo@bar'); $routes->add($route, 'foo'); $this->assertEquals($route, $routes->getByAction('foo@bar')); }
/** * 根据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); }