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


PHP ModuleRouteListener::onRoute方法代码示例

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


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

示例1: testRemovesModuleRouteListenerParamsWhenReusingMatchedParameters

 public function testRemovesModuleRouteListenerParamsWhenReusingMatchedParameters()
 {
     $router = new \Zend\Mvc\Router\Http\TreeRouteStack();
     $router->addRoute('default', array('type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => array('route' => '/:controller/:action', 'defaults' => array(ModuleRouteListener::MODULE_NAMESPACE => 'ZendTest\\Mvc\\Controller\\TestAsset', 'controller' => 'SampleController', 'action' => 'Dash')), 'child_routes' => array('wildcard' => array('type' => 'Zend\\Mvc\\Router\\Http\\Wildcard', 'options' => array('param_delimiter' => '=', 'key_value_delimiter' => '%')))));
     $routeMatch = new RouteMatch(array(ModuleRouteListener::MODULE_NAMESPACE => 'ZendTest\\Mvc\\Controller\\TestAsset', 'controller' => 'Rainbow'));
     $routeMatch->setMatchedRouteName('default/wildcard');
     $event = new MvcEvent();
     $event->setRouter($router)->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($event);
     $controller = new SampleController();
     $controller->setEvent($event);
     $url = $controller->plugin('url')->fromRoute('default/wildcard', array('Twenty' => 'Cooler'), true);
     $this->assertEquals('/Rainbow/Dash=Twenty%Cooler', $url);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:15,代码来源:UrlTest.php

示例2: testUsingNamespaceRouteParameterGivesSameResultAsFullControllerParameter

 public function testUsingNamespaceRouteParameterGivesSameResultAsFullControllerParameter()
 {
     $controller1 = 'MappedNs\\Foo\\Controller\\Bar\\Baz\\Sample';
     $this->routeMatch->setParam('controller', $controller1);
     $this->listener->injectActionHandles($this->event);
     $handles1 = $this->updater->getHandles();
     $controller2 = 'MappedNs\\Foo\\Controller\\Bar';
     $this->routeMatch->setParam(ModuleRouteListener::MODULE_NAMESPACE, $controller2);
     $this->routeMatch->setParam('controller', 'Baz\\Sample');
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($this->event);
     $this->listener->injectActionHandles($this->event);
     $handles2 = $this->updater->getHandles();
     $this->assertEquals($handles1, $handles2);
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:15,代码来源:ActionHandlesListenerTest.php

示例3: 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:benivaldo,项目名称:zf2-na-pratica,代码行数:31,代码来源:MvcTest.php

示例4: testKeepUrlQueryParameters

 public function testKeepUrlQueryParameters()
 {
     $expects = '/ctl/sample';
     $this->request->setMethod('POST');
     $this->request->setUri($expects);
     $this->request->setQuery(new Parameters(['id' => '123']));
     $routeMatch = $this->event->getRouter()->match($this->request);
     $this->event->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($this->event);
     $this->controller->dispatch($this->request, $this->response);
     $plugin = $this->plugin;
     $prgResultRoute = $plugin();
     $this->assertInstanceOf('Zend\\Http\\Response', $prgResultRoute);
     $this->assertTrue($prgResultRoute->getHeaders()->has('Location'));
     $this->assertEquals($expects . '?id=123', $prgResultRoute->getHeaders()->get('Location')->getUri(), 'expects to redirect for the same url');
     $this->assertEquals(303, $prgResultRoute->getStatusCode());
 }
开发者ID:zendframework,项目名称:zend-mvc-plugin-prg,代码行数:18,代码来源:PostRedirectGetTest.php

示例5: testReuseMatchedParametersWithSegmentController

 public function testReuseMatchedParametersWithSegmentController()
 {
     $expects = '/ctl/sample';
     $this->request->setMethod('POST');
     $this->request->setUri($expects);
     $this->request->setPost(new Parameters(['postval1' => 'value1']));
     $routeMatch = $this->event->getRouter()->match($this->request);
     $this->event->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($this->event);
     $this->controller->dispatch($this->request, $this->response);
     $plugin = $this->plugin;
     $prgResultRoute = $plugin($this->form);
     $this->assertInstanceOf(Response::class, $prgResultRoute);
     $this->assertTrue($prgResultRoute->getHeaders()->has('Location'));
     $this->assertEquals($expects, $prgResultRoute->getHeaders()->get('Location')->getUri(), 'redirect to the same url');
     $this->assertEquals(303, $prgResultRoute->getStatusCode());
 }
开发者ID:zendframework,项目名称:zend-mvc-plugin-fileprg,代码行数:18,代码来源:FilePostRedirectGetTest.php

示例6: testInheritedRouteMatchParamsWorkWithModuleRouteListener

 public function testInheritedRouteMatchParamsWorkWithModuleRouteListener()
 {
     $page = new Page\Mvc(array('label' => 'mpinkstonwashere', 'route' => 'lmaoplane'));
     $route = new SegmentRoute('/lmaoplane[/:controller]');
     $router = new TreeRouteStack();
     $router->addRoute('lmaoplane', $route);
     $routeMatch = new RouteMatch(array(ModuleRouteListener::MODULE_NAMESPACE => 'Application\\Controller', 'controller' => 'index'));
     $routeMatch->setMatchedRouteName('lmaoplane');
     $event = new MvcEvent();
     $event->setRouter($router)->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($event);
     $page->setRouter($event->getRouter());
     $page->setRouteMatch($event->getRouteMatch());
     $this->assertEquals('/lmaoplane', $page->getHref());
     $page->setUseRouteMatch(true);
     $this->assertEquals('/lmaoplane/index', $page->getHref());
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:18,代码来源:MvcTest.php

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

示例8: testUsingNamespaceRouteParameterGivesSameResultAsFullControllerParameter

 public function testUsingNamespaceRouteParameterGivesSameResultAsFullControllerParameter()
 {
     $this->routeMatch->setParam('controller', 'MappedNs\\Foo\\Controller\\Bar\\Baz\\Sample');
     $myViewModel = new ViewModel();
     $this->event->setResult($myViewModel);
     $this->listener->injectTemplate($this->event);
     $template1 = $myViewModel->getTemplate();
     $this->routeMatch->setParam(ModuleRouteListener::MODULE_NAMESPACE, 'MappedNs\\Foo\\Controller\\Bar');
     $this->routeMatch->setParam('controller', 'Baz\\Sample');
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($this->event);
     $myViewModel = new ViewModel();
     $this->event->setResult($myViewModel);
     $this->listener->injectTemplate($this->event);
     $this->assertEquals($template1, $myViewModel->getTemplate());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:16,代码来源:InjectTemplateListenerTest.php


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