/** * Verifica se precisa fazer a autorização do acesso * @param MvcEvent $event Evento * @return boolean */ public function mvcPreDispatch($event) { $di = $event->getTarget()->getServiceLocator(); $routeMatch = $event->getRouteMatch(); $moduleName = $routeMatch->getParam('module'); $controllerName = $routeMatch->getParam('controller'); // if ($moduleName == 'admin' && $controllerName != 'Admin\Controller\Auth') { // $authService = $di->get('Admin\Service\Auth'); // if (! $authService->authorize()) { // $redirect = $event->getTarget()->redirect(); // $redirect->toUrl('/admin/auth'); // } // } $actionName = $routeMatch->getParam('action'); $authService = $di->get('Admin\\Service\\Auth'); if (!$authService->authorize($moduleName, $controllerName, $actionName)) { throw new \Exception('Você não tem permissão para acessar este recurso'); } return true; }