protected function setUp()
 {
     parent::setUp();
     ServiceLocatorFactory::setInstance($this->getServiceManager());
     $this->controller = new AlboPretorioSearchController();
     $this->controller->setServiceLocator(ServiceLocatorFactory::getInstance());
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->serviceManager);
 }
 protected function setUp()
 {
     parent::setUp();
     ServiceLocatorFactory::setInstance($this->getServiceManager());
     $this->controller = new StatoCivileExportController();
     $this->controller->setServiceLocator(ServiceLocatorFactory::getInstance());
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->serviceManager);
 }
 protected function setUp()
 {
     parent::setUp();
     ServiceLocatorFactory::setInstance($this->getServiceManager());
     $this->controller = new UsersRecoverPasswordController();
     $this->controller->setServiceLocator(ServiceLocatorFactory::getInstance());
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->serviceManager);
 }
 protected function setUp()
 {
     parent::setUp();
     ServiceLocatorFactory::setInstance($this->getServiceManager());
     $this->controller = $this->getMockForAbstractClass('\\Application\\Controller\\SetupAbstractController');
     $this->controller->setServiceLocator(ServiceLocatorFactory::getInstance());
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->serviceManager);
 }
 protected function setUp()
 {
     parent::setUp();
     ServiceLocatorFactory::setInstance($this->getServiceManager());
     $this->controller = new CookieWarningController();
     $this->controller->setServiceLocator(ServiceLocatorFactory::getInstance());
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->serviceManager);
 }
Example #6
0
 /**
  * @param MvcEvent $e
  * @throws \Exception
  * @throws \ServiceLocatorFactory\NullServiceLocatorException
  */
 public function preDispatch(MvcEvent $e)
 {
     $application = $e->getApplication();
     $sm = $application->getServiceManager();
     $router = $sm->get('router');
     $request = $sm->get('request');
     $matchedRoute = $router->match($request);
     $params = $matchedRoute->getParams();
     $controller = $params['controller'];
     if (!isset($controller)) {
         return false;
     }
     $currentControllerNamespace = explode('\\', $controller);
     if ($currentControllerNamespace[0] == 'Admin') {
         $sl = ServiceLocatorFactory::getInstance();
         $session = new SessionContainer();
         $userDetails = $session->offsetGet('userDetails');
         /* Check Admin Area login */
         if (!$sl->get('AuthService')->hasIdentity() or $userDetails->sitename != $this->recoverSitename($sl)) {
             $url = $e->getRouter()->assemble(array('action' => 'index'), array('name' => 'login'));
             $response = $e->getResponse();
             $response->getHeaders()->addHeaderLine('Location', $url);
             $response->setStatusCode(302);
             $response->sendHeaders();
             exit;
         }
         // Check ACL
         $roles = (include __DIR__ . '/config/module.acl.roles.php');
         foreach ($roles as $key => $value) {
             if ($key == $matchedRoute->getMatchedRouteName()) {
                 if (isset($value['resources'])) {
                     $allowed = 0;
                     foreach ($value['resources'] as $resource) {
                         if ($userDetails->acl->hasResource($resource)) {
                             $allowed = 1;
                         }
                     }
                     /* No permissions, redirect... */
                     if ($allowed == 0) {
                         $url = $e->getRouter()->assemble(array('lang' => 'it'), array('name' => 'admin/not-authorized'));
                         $response = $e->getResponse();
                         $response->getHeaders()->addHeaderLine('Location', $url);
                         $response->setStatusCode(401);
                         $response->sendHeaders();
                         exit;
                     }
                 }
             }
         }
     }
 }
 /**
  *
  * @return \Zend\Mvc\I18n\Translator
  */
 private function getTranslator()
 {
     return ServiceLocatorFactory::getInstance()->get('translator');
 }
Example #8
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(MvcEvent $e)
 {
     ServiceLocatorFactory::setInstance($e->getApplication()->getServiceManager());
 }
 public function testSetinstance()
 {
     ServiceLocatorFactory::setInstance($this->getServiceManager());
     $this->assertTrue(ServiceLocatorFactory::getInstance() instanceof ServiceManager);
 }