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


PHP TreeRouteStack::addRoutes方法代码示例

本文整理汇总了PHP中Zend\Mvc\Router\Http\TreeRouteStack::addRoutes方法的典型用法代码示例。如果您正苦于以下问题:PHP TreeRouteStack::addRoutes方法的具体用法?PHP TreeRouteStack::addRoutes怎么用?PHP TreeRouteStack::addRoutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Mvc\Router\Http\TreeRouteStack的用法示例。


在下文中一共展示了TreeRouteStack::addRoutes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createService

 /**
  * Create and return the router
  *
  * Retrieves the "router" key of the Config service, and uses it
  * to instantiate the router. Uses the TreeRouteStack implementation by
  * default.
  *
  * @param  ServiceLocatorInterface        $serviceLocator
  * @param  string|null                     $cName
  * @param  string|null                     $rName
  * @return \Zend\Mvc\Router\RouteStackInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
 {
     $config = $serviceLocator->get('Config');
     $routePluginManager = $serviceLocator->get('RoutePluginManager');
     if ($rName === 'ConsoleRouter' || $cName === 'router' && Console::isConsole()) {
         // We are in a console, use console router.
         if (isset($config['console']) && isset($config['console']['router'])) {
             $routerConfig = $config['console']['router'];
         } else {
             $routerConfig = array();
         }
         $router = new ConsoleRouter($routePluginManager);
     } else {
         // This is an HTTP request, so use HTTP router
         $router = new HttpRouter($routePluginManager);
         $routerConfig = isset($config['router']) ? $config['router'] : array();
     }
     if (isset($routerConfig['route_plugins'])) {
         $router->setRoutePluginManager($routerConfig['route_plugins']);
     }
     if (isset($routerConfig['routes'])) {
         $router->addRoutes($routerConfig['routes']);
     }
     if (isset($routerConfig['default_params'])) {
         $router->setDefaultParams($routerConfig['default_params']);
     }
     return $router;
 }
开发者ID:totolouis,项目名称:ZF2-Auth,代码行数:40,代码来源:RouterFactory.php

示例2: setUpRouter

 public function setUpRouter()
 {
     if (isset($this->router)) {
         return;
     }
     $this->setUpRequest();
     $routes = ['resource' => ['type' => 'Segment', 'options' => ['route' => '/api/resource[/:id]', 'defaults' => ['controller' => 'Api\\RestController']]]];
     $this->router = $router = new TreeRouteStack();
     $router->addRoutes($routes);
     $matches = $router->match($this->request);
     if (!$matches instanceof RouteMatch) {
         $this->fail('Failed to route!');
     }
     $this->matches = $matches;
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:15,代码来源:CollectionIntegrationTest.php

示例3: testPriorityIsPassedToPartRoute

 public function testPriorityIsPassedToPartRoute()
 {
     $stack = new TreeRouteStack();
     $stack->addRoutes(array('foo' => array('type' => 'Literal', 'priority' => 1000, 'options' => array('route' => '/foo', 'defaults' => array('controller' => 'foo')), 'may_terminate' => true, 'child_routes' => array('bar' => array('type' => 'Literal', 'options' => array('route' => '/bar', 'defaults' => array('controller' => 'foo', 'action' => 'bar')))))));
     $reflectedClass = new \ReflectionClass($stack);
     $reflectedProperty = $reflectedClass->getProperty('routes');
     $reflectedProperty->setAccessible(true);
     $routes = $reflectedProperty->getValue($stack);
     $this->assertEquals(1000, $routes->get('foo')->priority);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:10,代码来源:TreeRouteStackTest.php

示例4: setUpAlternateRouter

 public function setUpAlternateRouter()
 {
     $routes = array('parent' => array('type' => 'Segment', 'options' => array('route' => '/api/parent[/:id]', 'defaults' => array('controller' => 'Api\\ParentController')), 'may_terminate' => true, 'child_routes' => array('child' => array('type' => 'Segment', 'options' => array('route' => '/child[/:child_id]', 'defaults' => array('controller' => 'Api\\ChildController'))))));
     $this->router = $router = new TreeRouteStack();
     $router->addRoutes($routes);
     $this->helpers->get('url')->setRouter($router);
 }
开发者ID:noc-med,项目名称:zf-rest,代码行数:7,代码来源:ChildResourcesIntegrationTest.php

示例5: setupRouter

 /**
  * Sets up the router based on the configuration provided
  * 
  * @param  Application $application 
  * @return void
  */
 protected function setupRouter(AppContext $application)
 {
     $router = new Router();
     $router->addRoutes($this->config->routes);
     $application->setRouter($router);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:12,代码来源:Bootstrap.php

示例6: testRecursiveDetectIsActiveWhenRouteNameIsKnown

 public function testRecursiveDetectIsActiveWhenRouteNameIsKnown()
 {
     $parentPage = new Page\Mvc(array('label' => 'some Label', 'route' => 'parentPageRoute'));
     $childPage = new Page\Mvc(array('label' => 'child', 'route' => 'childPageRoute'));
     $parentPage->addPage($childPage);
     $router = new TreeRouteStack();
     $router->addRoutes(array('parentPageRoute' => array('type' => 'literal', 'options' => array('route' => '/foo', 'defaults' => array('controller' => 'fooController', 'action' => 'fooAction'))), 'childPageRoute' => array('type' => 'literal', 'options' => array('route' => '/bar', 'defaults' => array('controller' => 'barController', 'action' => 'barAction')))));
     $routeMatch = new RouteMatch(array(ModuleRouteListener::MODULE_NAMESPACE => 'Application\\Controller', 'controller' => 'barController', 'action' => 'barAction'));
     $routeMatch->setMatchedRouteName('childPageRoute');
     $event = new MvcEvent();
     $event->setRouter($router)->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($event);
     $parentPage->setRouter($event->getRouter());
     $parentPage->setRouteMatch($event->getRouteMatch());
     $childPage->setRouter($event->getRouter());
     $childPage->setRouteMatch($event->getRouteMatch());
     $this->assertTrue($childPage->isActive(true));
     $this->assertTrue($parentPage->isActive(true));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:20,代码来源:MvcTest.php


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