/** * * @param ServiceLocatorInterface $serviceLocator * @return ControllerGuardListener */ public function createService(ServiceLocatorInterface $serviceLocator) { /* @var $options ModuleOptions */ $options = $serviceLocator->get('UghAuthorization\\Options\\ModuleOptions'); /* @var $controllerGuard Guard */ $controllerGuard = $serviceLocator->get('UghAuthorization\\Guards\\ControllerGuard'); $viewModel = new ViewModel(); $viewModel->setTemplate($options->getUnauthorizedViewScript()); $controllerGuardListener = new ControllerGuardListener($controllerGuard); $controllerGuardListener->setErrorViewModel($viewModel); return $controllerGuardListener; }