private function beforeActionExecute() { $userId = (string) HttpContext::getInstance()->getSession()->userId; if ($userId !== "") { Helpers::redirect(''); } }
private function beforeActionExecute() { $userId = (string) HttpContext::getInstance()->getSession()->userId; if ($userId == "") { Helpers::redirect("users/login"); } $userRole = UserManager::getInstance()->getUserRole(intval($userId)); if (!in_array($userRole->getName(), $this->roles)) { throw new ApplicationException("Not enough permissions to see this page!"); } }
public static function init() { spl_autoload_register(function ($class) { $pathParams = explode('\\', $class); $path = implode(DIRECTORY_SEPARATOR, $pathParams); $path = str_replace($pathParams[0], "", $path); if (!file_exists(substr($path . '.php', 1))) { Helpers::redirect("error"); } require_once $path . '.php'; }); }
public function dispatch() { try { $this->initController(); View::$controllerName = $this->controllerName; View::$actionName = $this->actionName; call_user_func_array([$this->controller, $this->actionName], $this->requestParams); } catch (ApplicationException $e) { $_SESSION["errors"] = $e->getMessage(); Helpers::redirect("error"); } catch (\Exception $e) { Helpers::redirect("error"); } unset($_SESSION["errors"]); $_SESSION["binding-errors"] = []; }