本文整理匯總了PHP中Silex\ControllerCollection::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP ControllerCollection::add方法的具體用法?PHP ControllerCollection::add怎麽用?PHP ControllerCollection::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Silex\ControllerCollection
的用法示例。
在下文中一共展示了ControllerCollection::add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: match
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;
}
示例2: testConflictingRouteNames
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());
}
示例3: testControllerFreezing
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) {
}
}