/** * Execute controller and action */ public function run() { try { $controllerName = "\\{$this->_baseNamespace}\\App\\Controller\\" . str_replace('/', '\\', $this->_dir . $this->_controller); if (\class_exists($controllerName)) { $actionName = $this->_action . $this->_options['action-prefix']; /** @var $controller \Kalibri\Controller\Page*/ $controller = new $controllerName(); // Set global controller instance \Kalibri::controller($controller); //If exists method '_remap' call it and pass method name and params if (\method_exists($controller, '_remap')) { \call_user_func_array([$controller, '_remap'], [$actionName, $this->_params]); } elseif (\is_callable("{$controllerName}::{$actionName}")) { \call_user_func_array([$controller, $actionName], $this->_params); } else { throw new NotFound(); } // Check is controller already rendered by hand, if not render it if (!$controller->isRendered()) { \call_user_func_array([$controller, '_render'], []); } return $this; } } catch (NotFound $e) { \Kalibri::error()->showPageNotFound(); } catch (\Exception $e) { \Kalibri::error()->showException($e); } \Kalibri::error()->showPageNotFound(); return $this; }
/** * Show access denied page */ public function show403() { @ob_end_clean(); $viewName = \Kalibri::config()->get('error.view.403'); if ($viewName) { if (\Kalibri::controller() instanceof \Kalibri\Controller\Page) { \Kalibri::controller()->page()->setViewName($viewName)->render(); } else { (new \Kalibri\View($viewName))->render(); } } exit; }