/** * method: recoverServiceData * * todo: write documentation * * probably this should move to the service object and we should * wrap it up here instead of implementing it here */ protected function recoverServiceData($name = NULL, $handler = 0) { Amslib_Plugin_Service::hasData(); Amslib_Plugin_Service::processHandler($handler); if (!$name) { $name = $this; } return Amslib_Plugin_Service::getValidationData($name); }
/** * method: processHandler * * todo: write documentation */ public static function processHandler($id = 0) { self::$handler = isset(self::$serviceData[self::HD][$id]) ? self::$serviceData[self::HD][$id] : array(); return array_keys(Amslib_Array::valid(self::$handler)); }
/** * 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"]); }