/** * PHP 5 Constructor */ public function __construct() { parent::__construct(); $this->x_error_handler = function ($arr, $exception = false) { // if has fatal error if (!empty($arr['is_fatal'])) { if (is_callable(Route::getDefault500())) { Route::setDefault500(array("\\" . __NAMESPACE__ . "\\Controller", 'error500')); } return call_user_func_array(Route::getDefault500(), array($arr)); } }; $this->x_isexception = false; /** * Register */ set_error_handler(array($this, 'handleError')); set_exception_handler(array($this, 'handleException')); register_shutdown_function(array($this, 'handleShutdown')); }
/** * Default Not found output Handler */ public static function defaultNotFound() { // set Not Found route Route::setNotfound(); $template = Template::singleton(); $template_dir = $template->getActiveTemplateDirectory(); $file_404 = $template->x_404_file; if ($template_dir && $file_404 && is_string($file_404)) { if (is_file("{$template_dir}/{$file_404}")) { // using callback to prevent direct access return call_user_func(function ($a) { ob_start(); require $a; $content = ob_get_clean(); Response::write($content, true); }, "{$template_dir}/{$file_404}"); } } // empty }