/** * Returns an array with all solar system hrefs. When response time is critical, using this call is not recommended * due to it causing over 1100 calls to CREST when not already cached. * * @return array in the form solarSystemId => href */ public function getSolarSystemHrefs() { $dataKey = 'gathered:solarSystemHrefs'; try { $dataObj = $this->client->getCache()->getItem($dataKey); } catch (Exceptions\KeyNotFoundInCacheException $e) { //instantiate data object $cacheableArrayClass = Config::getIveeClassName('CacheableArray'); $dataObj = new $cacheableArrayClass($dataKey, 24 * 3600); //run the async queries $this->client->asyncGetMultiEndpointResponses($this->getConstellationHrefs(), function (Response $res) use($dataObj) { foreach ($res->content->systems as $system) { $dataObj->data[EndpointHandler::parseTrailingIdFromUrl($system->href)] = $system->href; } }, null, static::CONSTELLATION_REPRESENTATION); $this->client->getCache()->setItem($dataObj); } return $dataObj->data; }
require 'system/vendor/autoload.php'; function conf($name) { global $c; return $c[$name]; } require ROOT_DIR . "/system/modules/core/php/BaseHandler.php"; // EOF TODO remove /////////////////////////////////////////////////////////////////// $app = new \Slim\App(); /** * @param $string * @return string */ function mb_ucfirst($string) { return mb_strtoupper(mb_substr($string, 0, 1)) . mb_strtolower(mb_substr($string, 1)); } $isSys = $_GET['sys'] == 'sys'; require ROOT_DIR . '/' . ($isSys ? 'system' : 'custom') . '/modules/' . mb_strtolower($_GET['module']) . '/api/' . mb_ucfirst($_GET['endpoint']) . '.php'; // Define app routes $app->group('/api/' . ($isSys ? 'sys/' : '') . $_GET['module'] . '/' . $_GET['endpoint'], function () { $handler = new EndpointHandler(); $routes = $handler->getRoutes(); foreach ($routes as $httpMethod => $methodRoutes) { foreach ($methodRoutes as $url => $functionName) { call_user_func([$this, mb_strtolower($httpMethod)], $url, [$handler, $functionName]); } } }); // Run app $app->run();