function getRoutesFromDB() { $relations = array(); $relations = $this->getRelations(); $json_relations = JSONRouteRelation::getJSONRelations(); if (count($json_relations) > 0) { foreach ($json_relations as $route => $relation) { if (isset($relations[$route])) { $relations[$route] = array_merge($relations[$route], $relation); } else { $relations[$route] = $relation; } } } $result = DBController::Query("SHOW TABLES"); if ($result === false) { exit(ApiResponse::errorResponse(404)); } else { if (empty($result) === true) { exit(ApiResponse::errorResponse(204)); } else { foreach ($result as $k => $v) { $route = reset($v); $route = new Route(); $route->routeName = reset($v); if (isset($relations[$route->routeName])) { $route->routeFields = $this->getRouteFields($route, $relations[$route->routeName]); } else { $route->routeFields = $this->getRouteFields($route); } ResterUtils::Log("*** PRIMARY KEY: " . $route->routeName . " => " . $route->primaryKey->fieldName); $routes[$route->routeName] = $route; } } } ApiCacheManager::saveValueToCache(ROUTE_CACHE_KEY, $routes); return $routes; }
function showError($errorNumber) { $result = ApiResponse::errorResponse($errorNumber); exit($this->doResponse($result)); }