Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
 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) {
     }
 }