/** * Constructor */ public function __construct() { $this->_request = new Request(); $this->_response = new Response(); $this->_method = Connection::getMethod(); $this->setBasePath(dirname(@$_SERVER["DOCUMENT_ROOT"]) . "/areas"); $this->setPublicPath(@$_SERVER["DOCUMENT_ROOT"]); $this->setRoute(Connection::getPath()); }
/** * Renders an error template for PHP errors and Exceptions */ public function _onException($e) { $response = new Response(); $error = $this->_filterError($e); $data = ["status" => $this->_status, "title" => $this->_status . ": " . $error["type"], "description" => "There has been a problem of type (" . $error["type"] . ").", "address" => Server::getUrl(), "method" => Connection::getMethod(), "date" => date("F jS Y h:i:s A T"), "headers" => getallheaders(), "error" => $error]; // send error data to log file $this->log($error["type"] . ": " . $error["message"] . " in " . $error["file"] . " on line " . $error["line"] . "."); // send http reposnse if (Connection::isMethod("GET")) { // template has been set... if (!empty($this->_template) && is_file($this->_template)) { // send all data to template to be rendered as needed $response->sendTemplate($this->_status, $this->_template, $data); } // no template, send just error description for security reasons $response->sendText($this->_status, $data["description"]); } // non-GET, send error description data as JSON $response->sendJson($this->_status, ["status" => $this->_status, "error" => $data["description"]]); }