protected function acceptable(Event $evt, App $app) { //Can we generate this content type? if (($this->contentType = self::match($this->getHeader('Accept'), array_keys($this->acceptable))) === null) { $evt->stop(); $msg = "Can't generate a '.{$this->contentType}.' response"; $this->contentType = static::DEF; $this->accept = implode(', ', array_keys($this->acceptable)); throw new Exception\NotAcceptable($msg); } $app->di->set('responseWriter', $this->acceptable[$this->contentType], true); }
public function beforeDispatch(Event $event, Dispatcher $dispatcher) { $user = $this->session->get('auth'); $acl = $this->getAcl(); $role = $user && $user->role->role ? $user->role->role : 'guest'; $controller = $dispatcher->getControllerName(); $action = $dispatcher->getActionName(); $allowed = $acl->isAllowed($role, $controller, $action); if ($allowed != Acl::ALLOW) { //Flash feedback message if in dev environment if (strpos(APPLICATION_ENV, 'development') !== false) { $this->flash->error("Route failing in security plugin - Controller: {$controller}, Action: {$action}, Role: {$role}, Url:" . $this->router->getRewriteUri()); } //stop the event $event->stop(); $this->response->redirect(); return false; } }