private static function setRoute() { $controller = isset($_GET['c']) ? $_GET['c'] : "Index"; $controller .= 'Controller'; $action = isset($_GET['a']) ? $_GET['a'] : "index"; $action .= "Action"; define('CONTROLLER', $controller); define('ACTION', $action); if (class_exists($controller)) { $object = new $controller(); if (!method_exists($object, $action)) { $objects = new ErrorController(); if (method_exists($objects, 'emptyAction') && !DEBUG) { $objects->emptyAction(); } else { halt($controller . '控制器中,' . $action . '方法不存在'); } } else { $object->{$action}(); } } else { $object = new ErrorController(); $object->indexAction(); } }
private static function dispatchError(Exception $e, $renderType = null, $message = null, $status = 500) { Log::error($e); ob_clean(); header(sprintf('%s %d %s', $_SERVER['SERVER_PROTOCOL'], $status, self::getMessageByStatus($status))); require APPLICATION_PATH . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'ErrorController' . PHP_EXTENSION; $error = new ErrorController(); if (!empty($renderType)) { $error->setRenderType($renderType); } $error->indexAction($message); }