Esempio n. 1
3
 public static function exec()
 {
     if (self::$initiate) {
         return null;
     }
     self::trigger('init');
     self::$initiate = true;
     if (self::env('maintenance') === true) {
         self::stop(503);
     }
     self::trigger('changestatus', array(\UtilsStatusCode(), null));
     $route = Route::get();
     if ($route) {
         $mainController = $route['controller'];
         $parsed = explode(':', $mainController, 2);
         $mainController = '\\Controller\\' . strtr($parsed[0], '.', '\\');
         $action = $parsed[1];
         $run = new $mainController();
         call_user_func_array(array($run, $action), is_array($route['args']) ? $route['args'] : array());
         $run = null;
     } else {
         App::stop(404, 'Invalid route');
     }
     if (class_exists('\\Inphinit\\Response', false)) {
         Response::dispatchHeaders();
     }
     if (class_exists('\\Inphinit\\View', false)) {
         View::dispatch();
     }
     self::trigger('ready');
     self::trigger('finish');
 }
Esempio n. 2
1
 public static function renderError($type, $message, $file, $line)
 {
     if (empty(self::$views['error'])) {
         return null;
     }
     $data = self::details($message, $file, $line);
     if (!headers_sent() && Request::is('xhr')) {
         ob_start();
         self::unregister();
         Response::cache(0);
         Response::type('application/json');
         echo json_encode($data);
         App::abort(500);
     }
     View::render(self::$views['error'], $data);
 }
Esempio n. 3
0
 public function xml($root, $data, $charset = 'UTF-8')
 {
     if (empty($root) || false === ctype_alpha($root)) {
         Exception::raise('First argument in Response::xml requires a string', 2);
         return false;
     }
     if (false === is_array($data)) {
         Exception::raise('Second argument in Response::xml requires a array', 2);
         return false;
     }
     $default = '<?xml version="1.0"';
     if (is_string($charset)) {
         $default .= ' encoding="' . $charset . '"';
     }
     $default .= '?><' . $root . '></' . $root . '>';
     $xmlElement = new \SimpleXMLElement($default);
     self::generate($data, $xmlElement);
     $resp = new DefaultResponse();
     DefaultResponse::contentType('text/xml');
     $resp->data($xmlElement->asXML());
     $xmlElement = null;
 }