public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $service_locator_str = 'doctrine';
     $this->sm = $this->getServiceLocator();
     $doctrine = $this->sm->get($service_locator_str);
     $this->modelEvent = new eventModel($doctrine);
     $this->translator = Utility::translate();
     //check login
     $user = Utility::checkLogin($this);
     if (!is_object($user) && $user == 0) {
         $this->redirect()->toRoute('admin/child', array('controller' => 'login'));
     } else {
         $isPermission = Utility::checkRole($user->userType, ROLE_ADMIN);
         if ($isPermission == false) {
             $this->redirect()->toRoute('admin/child', array('controller' => 'login'));
         }
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $install = setupUtility::checkInstall();
     if ($install == true) {
         return $this->redirect()->toRoute('install');
     }
     //get doctrine service
     $this->serviceLocatorStr = 'doctrine';
     $this->sm = $this->getServiceLocator();
     $this->doctrineService = $this->sm->get($this->serviceLocatorStr);
     //get translate service
     $this->translator = Utility::translate();
     //check login
     $user = Utility::checkLogin();
     if (!is_object($user) && $user == 0) {
         $this->redirect()->toRoute('admin/child', array('controller' => 'login'));
     }
     if (!Utility::checkRole($user->userType, ROLE_ADMIN)) {
         $this->redirect()->toRoute('frontend/child', array('controller' => 'login'));
     }
     $this->init();
     return parent::onDispatch($e);
 }