本文整理汇总了PHP中Zend\Mvc\MvcEvent::setRouteMatch方法的典型用法代码示例。如果您正苦于以下问题:PHP MvcEvent::setRouteMatch方法的具体用法?PHP MvcEvent::setRouteMatch怎么用?PHP MvcEvent::setRouteMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\MvcEvent
的用法示例。
在下文中一共展示了MvcEvent::setRouteMatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAppNameNotSetWhenMissingInConfig
public function testAppNameNotSetWhenMissingInConfig()
{
$this->moduleOptions->setApplicationName('');
$this->client->expects($this->never())->method('setAppName');
$routeMatch = class_exists(RouteMatch::class) ? new RouteMatch([]) : new RouteMatchV2([]);
$this->event->setRouteMatch($routeMatch);
$this->listener->onRequest($this->event);
}
示例2: 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();
}
示例3: testAppNameNotSetWhenMissingInConfig
public function testAppNameNotSetWhenMissingInConfig()
{
$this->moduleOptions->setApplicationName("");
$this->client->expects($this->never())->method('setAppName');
$routeMatch = new \Zend\Mvc\Router\RouteMatch(array());
$this->event->setRouteMatch($routeMatch);
$this->listener->onRequest($this->event);
}
示例4: getEvent
/**
* Retrieve the composed event
*
* @return Event
*/
public function getEvent()
{
if (!isset($this->event)) {
$this->setEvent(new MvcEvent());
$this->event->setRouteMatch(new RouteMatch($this->routeParams));
}
return $this->event;
}
示例5: setup
public function setup()
{
parent::setup();
$this->controller = $this->serviceManager->get($this->controllerFQDN);
$this->request = new Request();
$this->routeMatch = new RouteMatch(array('router' => array('routes' => array($this->controllerRoute => $this->routes[$this->controllerRoute]))));
$this->event->setRouteMatch($this->routeMatch);
$this->controller->setEvent($this->event);
$this->controller->setServiceLocator($this->serviceManager);
}
示例6: 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);
}
示例7: setUp
/**
* Setup
*/
public function setUp()
{
$this->setFormManager(new \StrokerForm\FormManager());
$this->controller = new AjaxController($this->getFormManager());
$this->request = new Request();
$this->response = new Response();
$controllerName = strtolower(str_replace('Controller', '', get_class($this->controller)));
$this->routeMatch = new RouteMatch(array('controller' => $controllerName));
$this->event = new MvcEvent();
$this->event->setRouteMatch($this->routeMatch);
$this->controller->setEvent($this->event);
}
示例8: 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;
});
}
示例9: setUp
protected function setUp()
{
$this->console = $this->getMockOfConsole();
$this->controller = new IndexController();
$this->event = new MvcEvent();
$this->request = new Request();
$this->response = new Response();
$this->routeMatch = new RouteMatch(array('controller' => 'index'));
$this->controller->setConsole($this->console);
$this->controller->setEvent($this->event);
$this->event->setRequest($this->request);
$this->event->setResponse($this->response);
$this->event->setRouteMatch($this->routeMatch);
}
示例10: setup
/**
* Faz o setup dos testes. Executado antes de cada teste
* @return void
*/
public function setup()
{
parent::setup();
//instancia o controller
$this->controller = new $this->controllerFQDN();
//cria um novo request
$this->request = new Request();
//cria o routeMatch baseado nas configurações do módulo/aplicação
$this->routeMatch = new RouteMatch(array('router' => array('routes' => array($this->controllerRoute => $this->routes[$this->controllerRoute]))));
//configura a rota para o evento de MVC corrente
$this->event->setRouteMatch($this->routeMatch);
$this->controller->setEvent($this->event);
$this->controller->setServiceLocator($this->serviceManager);
}
示例11: 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);
}
示例12: 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);
}
示例13: setUp
public function setUp()
{
$this->eventManager = new EventManager();
$this->event = new MvcEvent();
$this->object = new TestObject();
$this->serviceLocator = new ServiceManager();
$this->docs = $this->getMockBuilder('WidRestApiDocumentator\\Service\\Docs')->disableOriginalConstructor()->getMock();
$this->serviceLocator->setService('WidRestApiDocumentator\\Service\\Docs', $this->docs);
$this->routeMatch = new RouteMatch(array('controller' => 'WidRestApiDocumentator\\Controller\\Docs'));
$this->event->setRouteMatch($this->routeMatch);
$this->request = new Request();
$this->response = new Response();
$this->object->setServiceLocator($this->serviceLocator);
$this->object->setEventManager($this->eventManager);
$this->object->setEvent($this->event);
}
示例14: 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);
}
示例15: setUp
public function setUp()
{
// Used by \KJSencha\Service\ApiFactory::createService
\Zend\Console\Console::overrideIsConsole(false);
$sl = ServiceManagerFactory::getServiceManager();
/* @var $manager DirectManager */
$manager = $sl->get('kjsencha.direct.manager');
/* @var $apiFactory \KJSencha\Direct\Remoting\Api\Api */
$api = $sl->get('kjsencha.api');
$this->controller = new DirectController($manager, $api);
$this->request = new Request();
$this->routeMatch = new RouteMatch(array('controller' => 'kjsencha_direct'));
$this->event = new MvcEvent();
$this->event->setRouteMatch($this->routeMatch);
$this->controller->setEvent($this->event);
}