public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null) { $router = parent::createService($serviceLocator, $cName, $rName); //get instance of the RoutePluginManager $routePluginManager = $router->getRoutePluginManager(); //set the ServiceLocator for the RoutePluginManager so we can use it in the route $routePluginManager->setServiceLocator($serviceLocator); return $router; }
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); }
private function prepareEvent($forApi = false) { if ($forApi) { $controllerMock = $this->getMock(AbstractApiActionController::class); } else { $controllerMock = $this->getMock(AbstractActionController::class); } $routerFactory = new RouterFactory(); $router = $routerFactory->createService(Bootstrap::getServiceManager()); $event = new MvcEvent(); $event->setTarget($controllerMock); $event->setRouter($router); $event->setResponse(new Response()); return $event; }
public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null) { $router = parent::createService($serviceLocator, $cName, $rName); $router->getRoutePluginManager()->setServiceLocator($serviceLocator); return $router; }