Ejemplo n.º 1
0
 public static function shutdown_handler()
 {
     if (!JsonApiApplication::$_init) {
         return;
     }
     try {
         if (JsonApiApplication::$caching === TRUE and JsonApiApplication::$_files_changed === TRUE) {
             // Write the file path cache
             JsonApiApplication::cache("JsonApiApplication::find_file()", JsonApiApplication::$_files);
         }
     } catch (Exception $e) {
         // Pass the exception to the handler
         JsonApiApplication_Exception::handler($e);
     }
     if (JsonApiApplication::$errors and $error = error_get_last() and in_array($error["type"], JsonApiApplication::$shutdown_errors)) {
         // Clean the output buffer
         ob_get_level() and ob_clean();
         // Fake an exception for nice debugging
         JsonApiApplication_Exception::handler(new ErrorException($error["message"], $error["type"], 0, $error["file"], $error["line"]));
         // Shutdown now to avoid a "death loop"
         exit(1);
     }
 }