public function match(Resource $resource, $routeType, $to) { $routeClass = $this->routeClass; /* @var $route Route */ $route = new $routeClass(); $route->setPath($resource->getPath($routeType)); $route->setDefault('_controller', $to); $route->setMethods($resource->getMethods($routeType)); $this->routeCollection->add($resource->getName($routeType), $route); return $route; }
public function testConflictingRouteNames() { $controllers = new ControllerCollection(); $mountedRootController = new Controller(new Route('/')); $controllers->add($mountedRootController); $mainRootController = new Controller(new Route('/')); $mainRootController->bindDefaultRouteName('main_'); $controllers->flush(); $this->assertNotEquals($mainRootController->getRouteName(), $mountedRootController->getRouteName()); }
public function testControllerFreezing() { $routes = new RouteCollection(); $controllers = new ControllerCollection($routes); $fooController = new Controller(new Route('/foo')); $fooController->bind('foo'); $controllers->add($fooController); $barController = new Controller(new Route('/bar')); $barController->bind('bar'); $controllers->add($barController); $controllers->flush(); try { $fooController->bind('foo2'); $this->fail(); } catch (ControllerFrozenException $e) { } try { $barController->bind('bar2'); $this->fail(); } catch (ControllerFrozenException $e) { } }