preg_match('/^\\/api\\/v(\\d+)\\//', $_SERVER['REQUEST_URI'], $matches); $version = floor(file_get_contents(__DIR__ . '/VERSION')); if ($matches && isset($matches[1]) && $matches[1] == 2) { $version = 2; } // Do not put .json at the end of the resource Explorer::$useFormatAsExtension = false; //Do not hide the API Explorer::$hideProtected = false; // Use /api/v1/projects uri Defaults::$useUrlBasedVersioning = true; if (ForgeConfig::get('DEBUG_MODE')) { $restler = new Restler(false, true); $restler->setSupportedFormats('JsonFormat', 'XmlFormat', 'HtmlFormat'); } else { $restler_cache = new RestlerCache(); Defaults::$cacheDirectory = $restler_cache->getAndInitiateCacheDirectory($version); $restler = new Restler(true, false); $restler->setSupportedFormats('JsonFormat', 'XmlFormat'); } // Do not let Restler find itself the domain, when behind a reverse proxy, it's // a mess. $restler->setBaseUrl($sys_default_domain); $restler->setAPIVersion($version); $core_resources_injector = new Tuleap\REST\ResourcesInjector(); $core_resources_injector->populate($restler); switch ($version) { case 2: $event = Event::REST_RESOURCES_V2; break; default:
private function invalidateRestler() { $this->logger->info('Invalidate Restler cache'); $restler = new RestlerCache(); $restler->invalidateCache(); }