当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::getRoutes方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:rcmonitor,项目名称:abboom_phalcon_code_example,代码行数:19,代码来源:RouterMatchesTest.php

示例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();
     }
 }
开发者ID:rcmonitor,项目名称:abboom_phalcon_code_example,代码行数:11,代码来源:ApiModuleRouteTest.php

示例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);
     }
 }
开发者ID:ant-hill,项目名称:phalcon-kernel-module,代码行数:19,代码来源:ArrayRouterTest.php

示例4: getRoutes

 public function getRoutes()
 {
     return parent::getRoutes();
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Router.php


注:本文中的Phalcon\Mvc\Router::getRoutes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。