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


PHP Http\TreeRouteStack类代码示例

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


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

示例1: createRouter

 protected function createRouter()
 {
     $route = new RegexRoute('/assets/(?<resourcePath>.*)', '/assets/%resourcePath%');
     $router = new TreeRouteStack();
     $router->addRoute('asset', $route);
     return $router;
 }
开发者ID:rhysr,项目名称:zf2assetic,代码行数:7,代码来源:AssetPathTest.php

示例2: setUp

 public function setUp()
 {
     $this->router = $router = new TreeRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $route2 = new Segment('/help');
     $router->addRoute('docs', $route2);
     $router->addRoute('hostname', ['type' => 'hostname', 'options' => ['route' => 'localhost.localdomain'], 'child_routes' => ['resource' => ['type' => 'segment', 'options' => ['route' => '/resource[/:id]'], 'may_terminate' => true, 'child_routes' => ['children' => ['type' => 'literal', 'options' => ['route' => '/children']]]], 'users' => ['type' => 'segment', 'options' => ['route' => '/users[/:id]']], 'contacts' => ['type' => 'segment', 'options' => ['route' => '/contacts[/:id]']], 'embedded' => ['type' => 'segment', 'options' => ['route' => '/embedded[/:id]']], 'embedded_custom' => ['type' => 'segment', 'options' => ['route' => '/embedded_custom[/:custom_id]']]]]);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $router->setRequestUri(new Http('http://localhost.localdomain/resource'));
     $controller = $this->controller = $this->getMock('Zend\\Mvc\\Controller\\AbstractRestfulController');
     $controller->expects($this->any())->method('getEvent')->will($this->returnValue($event));
     $this->urlHelper = $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $this->serverUrlHelper = $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $this->plugin = $plugin = new HalHelper();
     $plugin->setController($controller);
     $plugin->setUrlHelper($urlHelper);
     $plugin->setServerUrlHelper($serverUrlHelper);
     $linkExtractor = new LinkExtractor($serverUrlHelper, $urlHelper);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $plugin->setLinkCollectionExtractor($linkCollectionExtractor);
 }
开发者ID:antarus,项目名称:mystra-pve,代码行数:26,代码来源:HalTest.php

示例3: 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

示例4: testIsActiveReturnsTrueWhenMatchingRoute

 public function testIsActiveReturnsTrueWhenMatchingRoute()
 {
     $page = new Page\Mvc(array('label' => 'spiffyjrwashere', 'route' => 'lolfish'));
     $route = new LiteralRoute('/lolfish');
     $router = new TreeRouteStack();
     $router->addRoute('lolfish', $route);
     $routeMatch = new RouteMatch(array());
     $routeMatch->setMatchedRouteName('lolfish');
     $page->setRouter($router);
     $page->setRouteMatch($routeMatch);
     $this->assertEquals(true, $page->isActive());
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:12,代码来源:MvcTest.php

示例5: testHrefGeneratedIsRouteAware

 public function testHrefGeneratedIsRouteAware()
 {
     $page = new Page\Mvc(array('label' => 'foo', 'action' => 'myaction', 'controller' => 'mycontroller', 'route' => 'myroute', 'params' => array('page' => 1337)));
     $route = new RegexRoute('(lolcat/(?<action>[^/]+)/(?<page>\\d+))', '/lolcat/%action%/%page%', array('controller' => 'foobar', 'action' => 'bazbat', 'page' => 1));
     $router = new TreeRouteStack();
     $router->addRoute('myroute', $route);
     $routeMatch = new RouteMatch(array('controller' => 'foobar', 'action' => 'bazbat', 'page' => 1));
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $urlHelper->setRouteMatch($routeMatch);
     $page->setUrlHelper($urlHelper);
     $page->setRouteMatch($routeMatch);
     $this->assertEquals('/lolcat/myaction/1337', $page->getHref());
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:14,代码来源:MvcTest.php

示例6: matchUrl

 private function matchUrl($url, $urlHelper)
 {
     $url = 'http://localhost.localdomain' . $url;
     $request = new Request();
     $request->setUri($url);
     $router = new TreeRouteStack();
     $router->addRoute('hostname', ['type' => 'hostname', 'options' => ['route' => 'localhost.localdomain'], 'child_routes' => ['resource' => ['type' => 'segment', 'options' => ['route' => '/resource[/:id]']]]]);
     $match = $router->match($request);
     if ($match instanceof RouteMatch) {
         $urlHelper->setRouter($router);
         $urlHelper->setRouteMatch($match);
     }
     return $match;
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:14,代码来源:LinkExtractorTest.php

示例7: 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

示例8: setUp

 public function setUp()
 {
     $this->request = new Request();
     $this->helper = new QueryUrl($this->request);
     $this->router = TreeRouteStack::factory(['routes' => ['route-name' => new Literal('/foo/bar')]]);
     $this->helper->setRouter($this->router);
 }
开发者ID:jkhaled,项目名称:LearnZF2,代码行数:7,代码来源:QueryUrlTest.php

示例9: testIsActiveReturnsTrueWhenMatchingRouteWhileUsingModuleRouteListener

 public function testIsActiveReturnsTrueWhenMatchingRouteWhileUsingModuleRouteListener()
 {
     $page = new Page\Mvc(array('label' => 'mpinkstonwashere', 'route' => 'roflcopter', 'controller' => 'index'));
     $route = new LiteralRoute('/roflcopter');
     $router = new TreeRouteStack();
     $router->addRoute('roflcopter', $route);
     $routeMatch = new RouteMatch(array(ModuleRouteListener::MODULE_NAMESPACE => 'Application\\Controller', 'controller' => 'index'));
     $routeMatch->setMatchedRouteName('roflcopter');
     $event = new MvcEvent();
     $event->setRouter($router)->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($event);
     $page->setRouter($event->getRouter());
     $page->setRouteMatch($event->getRouteMatch());
     $this->assertEquals(true, $page->isActive());
 }
开发者ID:nieldm,项目名称:zf2,代码行数:16,代码来源:MvcTest.php

示例10: setUp

 public function setUp()
 {
     $config = (include __DIR__ . '/../../../config/module.config.php');
     $renderer = new PhpRenderer();
     $renderer->setResolver(new TemplateMapResolver($config['view_manager']['template_map']));
     $router = TreeRouteStack::factory($config['router']);
     $this->helper = new QrCodeHelper($renderer, $router, new QrCodeServiceMock('foobar'));
 }
开发者ID:acelaya,项目名称:zf2-acqrcode,代码行数:8,代码来源:QrCodeHelperTest.php

示例11: setUp

 public function setUp()
 {
     $router = new TreeRouteStack();
     $router->addRoute('home', LiteralRoute::factory(array('route' => '/', 'defaults' => array('controller' => 'ZendTest\\Mvc\\Controller\\TestAsset\\SampleController'))));
     $router->addRoute('sub', SegmentRoute::factory(array('route' => '/foo/:param', 'defaults' => array('param' => 1))));
     $router->addRoute('ctl', SegmentRoute::factory(array('route' => '/ctl/:controller', 'defaults' => array('__NAMESPACE__' => 'ZendTest\\Mvc\\Controller\\TestAsset', 'controller' => 'sample'))));
     $this->controller = new SampleController();
     $this->request = new Request();
     $this->event = new MvcEvent();
     $this->routeMatch = new RouteMatch(array('controller' => 'controller-sample', 'action' => 'postPage'));
     $this->event->setRequest($this->request);
     $this->event->setRouteMatch($this->routeMatch);
     $this->event->setRouter($router);
     $this->sessionManager = new SessionManager();
     $this->sessionManager->destroy();
     $this->controller->setEvent($this->event);
     $plugins = $this->controller->getPluginManager();
     $plugins->get('flashmessenger')->setSessionManager($this->sessionManager);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:19,代码来源:PostRedirectGetTest.php

示例12: getController

 public function getController($controllerClass, $controllerName, $action, $params = [])
 {
     $config = $this->getConfig();
     $controller = $this->getServiceManager()->get('ControllerLoader')->get($controllerClass);
     $event = new MvcEvent();
     $routerConfig = isset($config['router']) ? $config['router'] : [];
     $router = TreeRouteStack::factory($routerConfig);
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch(['controller' => $controllerName, 'action' => $action] + $params));
     $controller->setEvent($event);
     return $controller;
 }
开发者ID:argentinaluiz,项目名称:js_zf2_library,代码行数:12,代码来源:JSTestControllerCase.php

示例13: match

 /**
  * Attempt to match an incoming request to a registered route.
  *
  * @param PsrRequest $request
  * @return RouteResult
  */
 public function match(PsrRequest $request)
 {
     $match = $this->zf2Router->match(Psr7ServerRequest::toZend($request, true));
     if (null === $match) {
         return RouteResult::fromRouteFailure();
     }
     $allowedMethods = $this->getAllowedMethods($match->getMatchedRouteName());
     if (!$this->methodIsAllowed($request->getMethod(), $allowedMethods)) {
         return RouteResult::fromRouteFailure($allowedMethods);
     }
     return $this->marshalSuccessResultFromRouteMatch($match);
 }
开发者ID:ezimuel,项目名称:zend-expressive,代码行数:18,代码来源:Zf2.php

示例14: setUp

 protected function setUp()
 {
     //check if child class implements the correct interface
     if (!$this instanceof TestCaseAdapterInterface) {
         throw new \Exception(__CLASS__ . " : Line " . __LINE__ . " : Test Case could not executed. It must implement FrontCore\\TestsConfig\\TestCaseAdapterInterface", 500);
     }
     //end if
     //check if bootstrap instance has been set
     if (!$this->bootstrap) {
         throw new \Exception(__CLASS__ . " : Line " . __LINE__ . " : Test Case could not executed. Bootstrap instance is not set", 500);
     }
     //end if
     $this->serviceManager = $this->bootstrap->getServiceManager();
     //$this->controller = new IndexController();
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $config = $this->serviceManager->get('Config');
     $routerConfig = isset($config['router']) ? $config['router'] : array();
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     //$this->controller->setEvent($this->event);
     //$this->controller->setServiceLocator($serviceManager);
     //create logged in user
     $arr_user_data = array("id" => "1", "uname" => "user", "pword" => "5f4dcc3b5aa765d61d8327deb882cf99", "api_key" => "2c0f-828c-b184-f33f-2944-ad2d-f51c-e17a-7a13-ef2a-f581-8e2b", "phpunit" => TRUE);
     $objUserSession = $this->serviceManager->get("FrontUserLogin\\Models\\FrontUserSession")->createUserSession((object) $arr_user_data);
 }
开发者ID:BanterMediaSA,项目名称:majestic3-open-source,代码行数:28,代码来源:TestCaseAdapter.php

示例15: setUpController

 protected function setUpController(\Zend\Mvc\Controller\AbstractActionController $controller)
 {
     $config = (include 'config/application.config.php');
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $serviceManager->setAllowOverride(true);
     $this->controller = $controller;
     $this->request = new Request();
     $this->response = new Response();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $this->event->setRequest($this->request)->setResponse($this->response);
     $config = $serviceManager->get('Config');
     $routerConfig = isset($config['router']) ? $config['router'] : array();
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($serviceManager);
     $this->setupForwardPlugin();
     $this->setupParamsPlugin();
     $this->setupFormPlugin();
     $this->setupGridControllerPlugin();
     $this->setupControllerFilePlugin();
 }
开发者ID:noikiy,项目名称:tools,代码行数:26,代码来源:ControllerTestCase.php


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