本文整理汇总了PHP中Zend\Mvc\Router\Http\TreeRouteStack::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP TreeRouteStack::factory方法的具体用法?PHP TreeRouteStack::factory怎么用?PHP TreeRouteStack::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Router\Http\TreeRouteStack
的用法示例。
在下文中一共展示了TreeRouteStack::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: setUp
public function setUp()
{
$basePath = __DIR__ . '/../../../../../';
$this->setApplicationConfig(include $basePath . 'config/application.config.php');
$serviceManager = Bootstrap::getServiceManager();
$this->controller = new \Galaxy\Controller\IndexController();
$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);
$mockAuth = $this->getMock('ZfcUser\\Entity\\UserInterface');
$ZfcUserMock = $this->getMock('User\\Entity\\User');
$ZfcUserMock->expects($this->any())->method('getId')->will($this->returnValue('3'));
$authMock = $this->getMock('ZfcUser\\Controller\\Plugin\\ZfcUserAuthentication');
$authMock->expects($this->any())->method('hasIdentity')->will($this->returnValue(true));
$authMock->expects($this->any())->method('getIdentity')->will($this->returnValue($ZfcUserMock));
$this->controller->getPluginManager()->setService('zfcUserAuthentication', $authMock);
parent::setUp();
}
示例4: 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();
}
示例5: 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'));
}
示例6: getServiceConfig
/**
* {@inheritDoc}
*/
public function getServiceConfig()
{
return array('factories' => array('Application' => function (ServiceLocatorInterface $sl) {
return new App($sl->get('Config'), $sl);
}, 'Router' => function () {
return HttpRouter::factory(array());
}, 'HttpRouter' => function (ServiceLocatorInterface $sl) {
return $sl->get('Router');
}));
}
示例7: 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;
}
示例8: setUp
protected function setUp()
{
$this->controller = new ConfigurationRestController();
$this->request = new Request();
$this->routeMatch = new RouteMatch(array('controller' => 'rest_configuration'));
$this->event = new MvcEvent();
$config = Bootstrap::getServiceManager()->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(Bootstrap::getServiceManager());
}
示例9: createServiceLocator
/**
* @return ServiceLocatorInterface
*/
private function createServiceLocator(MvcEvent $e = null)
{
$sm = new ServiceManager();
$sm->setService('Request', new Request());
$sm->setService('Response', new Response());
$sm->setService('EventManager', new EventManager());
$sm->setService('Router', TreeRouteStack::factory(['routes' => []]));
$e = $e ?: new MvcEvent();
$app = $this->getMock('Zend\\Mvc\\Application', [], [[], $sm]);
$app->expects($this->any())->method('getMvcEvent')->willReturn($e);
$sm->setService('Application', $app);
$helperManager = new HelperPluginManager();
$helperManager->setServiceLocator($sm);
return $helperManager;
}
示例10: createServiceLocator
/**
* @return ServiceLocatorInterface
*/
private function createServiceLocator(MvcEvent $e = null)
{
$sm = new ServiceManager();
$sm->setService('Request', new Request());
$sm->setService('Response', new Response());
$sm->setService('EventManager', new EventManager());
$sm->setService('Router', TreeRouteStack::factory(['routes' => []]));
$e = $e ?: new MvcEvent();
$app = $this->prophesize('Zend\\Mvc\\Application');
$app->getMvcEvent()->willReturn($e);
$sm->setService('Application', $app->reveal());
$helperManager = new HelperPluginManager();
$helperManager->setServiceLocator($sm);
return $helperManager;
}
示例11: setUp
protected function setUp()
{
$serviceManager = $this->getServiceManager();
$this->controller = new IndexController();
$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
protected function setUp()
{
$this->serviceManager = ServiceManagerFactory::getServiceManager();
$this->controller = new IndexController();
$this->request = new Request();
$this->routeMatch = new RouteMatch(['controller' => IndexController::class]);
$this->event = new MvcEvent();
$config = $this->serviceManager->get('Config');
$routerConfig = isset($config['router']) ? $config['router'] : [];
$router = HttpRouter::factory($routerConfig);
$this->event->setRouter($router);
$this->event->setRouteMatch($this->routeMatch);
$this->controller->setEvent($this->event);
$this->controller->setServiceLocator($this->serviceManager);
}
示例14: 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);
}
示例15: 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);
}