Ejemplo n.º 1
0
 public static function setup($url, $trap_warnings = false)
 {
     self::$shutdown_url = $url;
     //	E_PARSE: you cannot catch parse errors without a prepend file.
     //	NOTE: I think this has to do with being a different apache request stage
     //	All the errors I believe to be fatal/non-recoverable/you're f****d/your code is shit
     self::$trap_list = $trap_warnings ? array_merge(self::$FATAL, self::$WARNINGS) : self::$FATAL;
     set_error_handler(array("Amslib_Shutdown", "__exception_error_handler"));
     register_shutdown_function(array("Amslib_Shutdown", "__shutdown_handler"));
     set_exception_handler(array("Amslib_Shutdown", "__shutdown_exception"));
 }
Ejemplo n.º 2
0
 /**
  * 	method:	runService
  *
  * 	todo: write documentation
  */
 public function runService()
 {
     //	NOTE: This might be presumptuous to say every webservice will output it's data in JSON format
     //	NOTE: obviously the webservice has an output format, we can detect session/json and set this appropriately
     Amslib_Shutdown::setMode("json");
     $route = Amslib_Router::getRoute();
     //	NOTE:	Perhaps die()'ing horribly like you just drove off a cliff in your
     //				lamborghini with a martini in one hand, a hooker blowing you whilst
     //				smoking an enormous cigar made of 100 dollar bills is NOT the best
     //				way to handle failure?
     //	NOTE:	However, check all the route data is valid before using it
     if (!$route) {
         Amslib_Debug::log($m = __METHOD__ . ": route is invalid, check error log", $route);
         die($m);
     }
     if (!isset($route["group"]) || !strlen($route["group"])) {
         Amslib_Debug::log($m = __METHOD__ . ": route/group is invalid, check error log", $route);
         die($m);
     }
     if (!isset($route["name"]) || !strlen($route["name"])) {
         Amslib_Debug::log($m = __METHOD__ . ": route/name is invalid, check error log", $route);
         die($m);
     }
     if (!isset($route["handler"]) || !is_array($route["handler"]) || empty($route["handler"])) {
         Amslib_Debug::log($m = __METHOD__ . ": route/handler is invalid or empty, check error log", $route);
         die($m);
     }
     if (!isset($route["output"])) {
         Amslib_Debug::log($m = __METHOD__ . ": route/handler is invalid, there was no output specified", $route);
         die($m);
     }
     $this->api->setupService($route["group"], $route["name"]);
     $service = Amslib_Plugin_Service::getInstance();
     $service->installHandlers($route["group"], $route["output"], $route["handler"]);
     $service->execute($route["optimise"]);
 }