/** * @param ServiceLocatorInterface $serviceLocator * * @return RouteCollection */ public function createService(ServiceLocatorInterface $serviceLocator) { /** @var array $config */ $config = $serviceLocator->get('config'); $config = isset($config['router']['routes']) ? $config['router']['routes'] : []; $builder = new RouteCollectionBuilder($config); return $builder->build(); }
public function testBuilder() { $routesConfig = $this->getRoutesConfig(); $builder = new RouteCollectionBuilder($routesConfig); $routeCollection = $builder->build(); $this->assertInstanceOf(FlatRouteCollection::class, $routeCollection); $routes = $routeCollection->getRoutes(); // "zf-debug-utils" $route = array_shift($routes); $this->assertEquals('zf-debug-utils', $route->getName()); $this->assertEquals('/_debug', $route->getUrl()); $this->assertEquals('IndexController', $route->getController()); $this->assertEquals('indexAction', $route->getAction()); // "zf-debug-utils/routes" $route = array_shift($routes); $this->assertEquals('zf-debug-utils/routes', $route->getName()); $this->assertEquals('/_debug/routes', $route->getUrl()); $this->assertEquals('HttpRoutesController', $route->getController()); $this->assertEquals('indexAction', $route->getAction()); // "zf-debug-utils/routes/do-match-route" $route = array_shift($routes); $this->assertEquals('zf-debug-utils/routes/do-match-route', $route->getName()); $this->assertEquals('/_debug/routes/match-route', $route->getUrl()); $this->assertEquals('HttpRoutesController', $route->getController()); $this->assertEquals('matchRouteAction', $route->getAction()); // "zf-debug-utils/routes/list" $route = array_shift($routes); $this->assertEquals('zf-debug-utils/routes/list', $route->getName()); $this->assertEquals('/_debug/routes/list', $route->getUrl()); $this->assertEquals('HttpRoutesController', $route->getController()); $this->assertEquals('listAllAction', $route->getAction()); // "zf-debug-utils/routes/match" $route = array_shift($routes); $this->assertEquals('zf-debug-utils/routes/match', $route->getName()); $this->assertEquals('/_debug/routes/match', $route->getUrl()); $this->assertEquals('HttpRoutesController', $route->getController()); $this->assertEquals('renderMatchRouteViewAction', $route->getAction()); }