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


PHP MvcEvent::setRouter方法代码示例

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


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

示例1: init

 public function init($controllerName, $actionName = 'index')
 {
     $this->routeMatch = new RouteMatch(['controller' => $controllerName, 'action' => $actionName]);
     $this->event = new MvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     $this->event->setRouter((new RouterFactory())->createService(Bootstrap::getServiceManager()));
     $this->prepareAuthenticateMock();
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:8,代码来源:AbstractControllerTestCase.php

示例2: init

 public function init($controllerName, $actionName = 'index', $lang = 'en')
 {
     $this->routeMatch = new RouteMatch(array('controller' => $controllerName, 'action' => $actionName, 'lang' => $lang));
     $this->event = new MvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     /** @var SimpleRouteStack $router */
     $routerFactory = new RouterFactory();
     $router = $routerFactory->createService(clone Bootstrap::getServiceManager());
     $router->setDefaultParam('lang', $lang);
     $this->event->setRouter($router);
 }
开发者ID:webpants,项目名称:YAWIK,代码行数:11,代码来源:AbstractControllerTestCase.php

示例3: setUp

 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->setApplicationConfig(include __DIR__ . '/../../../../../../tests/config/application.config.php');
     parent::setUp();
     $this->controller = new IdeaController();
     $this->request = new Request();
     $this->response = null;
     $this->routeMatch = new RouteMatch(['controller' => 'project-idea']);
     $this->event = new MvcEvent();
     $router = new SimpleRouteStack();
     $router->addRoute('idea/idea', ['type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => ['route' => "project/idea.html"]]);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     //Get the serviceLocation and inject it into the controller
     $serviceLocator = $this->getApplicationServiceLocator();
     $this->controller->setServiceLocator($serviceLocator);
     $formService = $serviceLocator->get(FormService::class);
     $this->controller->setFormService($formService);
     $ideaServiceMock = $this->getMockBuilder('Project\\Service\\IdeaService')->disableOriginalConstructor()->getMock();
     $newEntityResult = new Idea();
     $newEntityResult->setId(1);
     $ideaServiceMock->expects($this->any())->method('newEntity')->will($this->returnValue($newEntityResult));
     $ideaServiceMock->expects($this->any())->method('findAll')->will($this->returnValue([]));
     $this->controller->setIdeaService($serviceLocator->get(IdeaService::class));
     $serviceManager = $this->getApplicationServiceLocator();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService(IdeaService::class, $ideaServiceMock);
     $authorizeServiceMock = $this->getMockBuilder('BjyAuthorize\\View\\Helper\\IsAllowed')->disableOriginalConstructor()->getMock();
     $authorizeServiceMock->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $serviceManager = $this->getApplicationServiceLocator()->get('viewhelpermanager');
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('isAllowed', $authorizeServiceMock);
     $this->controller->getPluginManager()->setFactory('zfcUserAuthentication', function ($sm) {
         $serviceLocator = $sm->getController()->getServiceLocator();
         $authService = new AuthenticationService();
         $nonPersistent = new NonPersistent();
         /**
          * Store a reference if the contact in the session
          */
         $entityManager = $serviceLocator->get('doctrine.entitymanager.orm_default');
         $contact = $entityManager->getReference("Contact\\Entity\\Contact", 1);
         $nonPersistent->write($contact);
         $authService->setStorage($nonPersistent);
         $authAdapter = $serviceLocator->get('ZfcUser\\Authentication\\Adapter\\AdapterChain');
         $controllerPlugin = new \ZfcUser\Controller\Plugin\ZfcUserAuthentication();
         $controllerPlugin->setAuthService($authService);
         $controllerPlugin->setAuthAdapter($authAdapter);
         return $controllerPlugin;
     });
 }
开发者ID:debranova,项目名称:project,代码行数:54,代码来源:IdeaControllerTest.php

示例4: setUp

 protected function setUp()
 {
     $serviceManager = Bootstrap::getServiceManager();
     $this->controller = new HotelController();
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $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);
 }
开发者ID:breaktherules,项目名称:rest-hotel-client,代码行数:15,代码来源:HotelControllerTest.php

示例5: setUp

 protected function setUp()
 {
     $serviceManagerGrabber = new ServiceManagerGrabber();
     $this->serviceManager = $serviceManagerGrabber->getServiceManager();
     $this->serviceManager->setAllowOverride(true);
     $this->serviceManager->setService('doctrine.entitymanager.orm_default', $this->getEntityManagerMock());
     $config = $this->serviceManager->get('Config');
     $this->request = new PhpEnviromentRequest();
     $this->router = HttpRouter::factory(isset($config['router']) ? $config['router'] : array());
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->routeMatch->setParam('lang', 'it');
     $this->event = new MvcEvent();
     $this->event->setRouter($this->router);
     $this->event->setRouteMatch($this->routeMatch);
 }
开发者ID:usban,项目名称:entilocali,代码行数:15,代码来源:TestSuite.php

示例6: setUp

 /**
  * Setup for tests
  *
  * @return null
  */
 public function setUp()
 {
     $this->mockPageRepo = $this->getMockBuilder('\\Rcm\\Repository\\Page')->disableOriginalConstructor()->getMock();
     $this->mockPageRepo->expects($this->any())->method('getPageByName')->will($this->returnCallback([$this, 'pageRepoMockCallback']));
     $mockLayoutManager = $this->getMockBuilder('\\Rcm\\Service\\LayoutManager')->disableOriginalConstructor()->getMock();
     $mockLayoutManager->expects($this->any())->method('getSiteLayout')->will($this->returnCallback([$this, 'layoutManagerMockCallback']));
     $this->mockUserServicePlugin = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\RcmIsAllowed')->disableOriginalConstructor()->getMock();
     $this->mockIsPageAllowed = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\RcmIsPageAllowed')->disableOriginalConstructor()->getMock();
     $this->mockShouldShowRevisions = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\ShouldShowRevisions')->disableOriginalConstructor()->getMock();
     $this->mockRedirectToPage = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\RedirectToPage')->disableOriginalConstructor()->getMock();
     $this->mockIsSiteAdmin = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\IsSiteAdmin')->disableOriginalConstructor()->getMock();
     $this->currentSite = new Site();
     $this->currentSite->setSiteId(1);
     $this->currentSite->setNotFoundPage('not-found');
     $config = ['contentManager' => ['type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => ['route' => '/rcm[/:page][/:revision]', 'defaults' => ['controller' => 'Rcm\\Controller\\IndexController', 'action' => 'index']]], 'contentManagerWithPageType' => ['type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => ['route' => '/rcm/:pageType/:page[/:revision]', 'constraints' => ['pageType' => '[a-z]'], 'defaults' => ['controller' => 'Rcm\\Controller\\IndexController', 'action' => 'index']]]];
     /** @var \Rcm\Service\LayoutManager $mockLayoutManager */
     $this->controller = new IndexController($mockLayoutManager, $this->currentSite, $this->mockPageRepo);
     $this->controller->getPluginManager()->setService('rcmIsAllowed', $this->mockUserServicePlugin)->setService('shouldShowRevisions', $this->mockShouldShowRevisions)->setService('redirectToPage', $this->mockRedirectToPage)->setService('rcmIsSiteAdmin', $this->mockIsSiteAdmin)->setService('rcmIsPageAllowed', $this->mockIsPageAllowed);
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(['controller' => 'index']);
     $this->event = new MvcEvent();
     $routerConfig = $config;
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
 }
开发者ID:reliv,项目名称:rcm,代码行数:32,代码来源:IndexControllerTest.php

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

示例8: setUp

 public function setUp()
 {
     $this->controller = $controller = new RestController();
     $this->router = $router = new SimpleRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch([]));
     $controller->setEvent($event);
     $controller->setRoute('resource');
     $pluginManager = new PluginManager();
     $pluginManager->setService('bodyParams', new BodyParams());
     $controller->setPluginManager($pluginManager);
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $linksHelper = new HalHelper();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $linkExtractor = new LinkExtractor($serverUrlHelper, $urlHelper);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $linksHelper->setLinkCollectionExtractor($linkCollectionExtractor);
     $pluginManager->setService('Hal', $linksHelper);
     $linksHelper->setController($controller);
     $this->resource = $resource = new Resource();
     $controller->setResource($resource);
 }
开发者ID:louiselista,项目名称:BlueSystem,代码行数:30,代码来源:RestControllerTest.php

示例9: setUp

 public function setUp()
 {
     parent::setUp();
     $this->_serviceManager = \Bootstrap::getServiceManager();
     $this->controller = new GridController();
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array());
     $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($this->_serviceManager);
 }
开发者ID:kdrezo,项目名称:zf2-datagrid,代码行数:16,代码来源:BaseTestClass.php

示例10: setUp

 public function setUp()
 {
     $routerClass = class_exists(V2TreeRouteStack::class) ? V2TreeRouteStack::class : TreeRouteStack::class;
     $routeClass = class_exists(V2Segment::class) ? V2Segment::class : Segment::class;
     $this->router = $router = new $routerClass();
     $route = new $routeClass('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $route2 = new $routeClass('/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->prophesize(AbstractRestfulController::class);
     $controller->getEvent()->willReturn($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->reveal());
     $linkUrlBuilder = new LinkUrlBuilder($serverUrlHelper, $urlHelper);
     $plugin->setLinkUrlBuilder($linkUrlBuilder);
     $linkExtractor = new LinkExtractor($linkUrlBuilder);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $plugin->setLinkCollectionExtractor($linkCollectionExtractor);
 }
开发者ID:zfcampus,项目名称:zf-hal,代码行数:28,代码来源:HalTest.php

示例11: setUp

 public function setUp()
 {
     $this->controller = $controller = new ResourceController();
     $this->router = $router = new SimpleRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch(array()));
     $controller->setEvent($event);
     $controller->setRoute('resource');
     $pluginManager = new PluginManager();
     $controller->setPluginManager($pluginManager);
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $linksHelper = new Plugin\HalLinks();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $pluginManager->setService('HalLinks', $linksHelper);
     $linksHelper->setController($controller);
     $this->resource = $resource = new Resource();
     $controller->setResource($resource);
 }
开发者ID:davidbrabrand,项目名称:PhlyRestfully,代码行数:26,代码来源:ResourceControllerTest.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     $this->controller = new $this->controllerStringName();
     $this->request = $this->controller->getRequest();
     $this->response = $this->controller->getResponse();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $config = $this->getService('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($this->serviceManager);
 }
开发者ID:michelcandido,项目名称:zf2-doctrine-tests,代码行数:16,代码来源:CoreControllerTestCase.php

示例13: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $callback = function ($e) {
         $e->setRouter(new ConsoleRouter());
     };
     $events = $e->getApplication()->getEventManager();
     $events->attach('route', $callback, 10000);
 }
开发者ID:no-reply,项目名称:cbpl-vufind,代码行数:8,代码来源:Module.php

示例14: setUp

 /**
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $oServiceManager = \TranslatorToolsTest\Bootstrap::getServiceManager();
     $this->configuration = \Zend\Stdlib\ArrayUtils::merge($oServiceManager->get('Config'), include __DIR__ . '/../configuration.php');
     $bAllowOverride = $oServiceManager->getAllowOverride();
     if (!$bAllowOverride) {
         $oServiceManager->setAllowOverride(true);
     }
     $oServiceManager->setService('Config', $this->configuration)->setAllowOverride($bAllowOverride);
     $this->controller = new \TranslatorTools\Controller\ToolsController();
     $this->request = new \Zend\Http\Request();
     $this->routeMatch = new \Zend\Mvc\Router\RouteMatch(array('controller' => 'tools'));
     $this->event = new \Zend\Mvc\MvcEvent();
     $this->event->setRouter(\Zend\Mvc\Router\Http\TreeRouteStack::factory(isset($this->configuration['router']) ? $this->configuration['router'] : array()))->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($oServiceManager);
 }
开发者ID:neilime,项目名称:zf2-translator-tools,代码行数:20,代码来源:ToolsControllerTest.php

示例15: setUp

 protected function setUp()
 {
     $serviceManager = Bootstrap::getServiceManager();
     $this->fileSystem = vfsStream::setup('public', null, array('img' => array('test.jpg' => file_get_contents(__DIR__ . '/../../_files/test.jpg')), 'processed' => array()));
     /** @var \TckImageResizer\Service\ImageProcessing $imageProcessing */
     $imageProcessing = $serviceManager->get('TckImageResizer\\Service\\ImageProcessing');
     $this->controller = new IndexController($imageProcessing, vfsStream::url('public'));
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $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);
 }
开发者ID:tck,项目名称:zf2-imageresizer,代码行数:18,代码来源:IndexControllerTest.php


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