本文整理汇总了PHP中Phalcon\Mvc\Router::getRoutes方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::getRoutes方法的具体用法?PHP Router::getRoutes怎么用?PHP Router::getRoutes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Router
的用法示例。
在下文中一共展示了Router::getRoutes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->router = new Router();
$this->router->add('/api/web/v1/:controller', array('module' => 'api', 'action' => 'index', 'controller' => 1))->setName('single_controller');
$this->router->add('/api/web/v{version}', array('module' => 'api', 'action' => 'index', 'controller' => 'index'))->setName('simple_version');
$this->router->add('/api/web/v{major:[0-9]{1,2}}\\.{minor:[0-9]{1,2}}', array('module' => 'api', 'action' => 'index', 'controller' => 'index'))->setName('syntax_version');
$this->router->add('/api/web/v{major:[0-9]{1,2}}\\.{minor:[0-9]{1,2}}/:controller/:action', array('module' => 'api', 'action' => 4, 'controller' => 3))->setName('syntax_version_action_controller');
$this->router->add('/api/mobile/v{major:[0-9]{1,2}}\\.{minor:[0-9]{1,2}}/:controller/:action/:params', array('module' => 'api', 'action' => 4, 'controller' => 3, 'params' => 5))->setName('syntax_version_action_controller_parameters');
$this->router->add('/api/mobile/v{major:[0-9]{1,2}}\\.{minor:[0-9]{1,2}}/:controller/:action/:int', array('module' => 'api', 'action' => 4, 'controller' => 3, 'id' => 5))->setName('syntax_version_action_controller_id');
$this->router->add('/api/{media}/v{major:[0-9]{1,2}}\\.{minor:[0-9]{1,2}}/:controller/:action/:int', array('module' => 'api', 'action' => 5, 'controller' => 4, 'id' => 6))->setName('media_syntax_version_action_controller_id');
$arRoutes = $this->router->getRoutes();
/**
* @type Router\Route $oRoute
*/
foreach ($arRoutes as $oRoute) {
$this->routes[] = $oRoute->getPattern();
}
}
示例2: setExistingRoutes
private function setExistingRoutes()
{
$arRoutes = $this->router->getRoutes();
/**
* @type Router\Route $oRoute
*/
foreach ($arRoutes as $oRoute) {
$strRouteName = $oRoute->getName();
$this->routes[$strRouteName] = $oRoute->getPattern();
}
}
示例3: testAnnotations
public function testAnnotations()
{
$di = new Di();
$di['request'] = new \Phalcon\Http\Request();
$router = new Router(false);
$router->setDI($di);
$loader = new ArrayRouteLoader($router);
$loader->load(include __DIR__ . '/Fixtures/routes.php');
$router->handle();
$this->assertCount(3, $router->getRoutes());
$routes = [['uri' => '/test4', 'method' => 'GET', 'controller' => 'test4', 'action' => 'test4'], ['uri' => '/test4', 'method' => 'POST', 'controller' => 'test4', 'action' => 'test4'], ['uri' => '/test5', 'method' => 'POST', 'controller' => 'test5', 'action' => 'test5'], ['uri' => '/test6', 'method' => 'GET', 'controller' => 'test6', 'action' => 'test6']];
foreach ($routes as $route) {
$_SERVER['REQUEST_METHOD'] = $route['method'];
$router->handle($route['uri']);
$this->assertEquals($router->getControllerName(), $route['controller']);
$this->assertEquals($router->getActionName(), $route['action']);
$this->assertEquals($router->isExactControllerName(), true);
}
}
示例4: getRoutes
public function getRoutes()
{
return parent::getRoutes();
}