/** * Describes api spec * * @param \Scalr_UI_Response $response Response object */ public function describe(\Scalr_UI_Response $response) { $cacheChanged = is_readable($this->cacheFile) ? filemtime($this->cacheFile) : null; $specChanged = filemtime($this->specFile); $configChanged = filemtime($this->config->getPath()); if ($cacheChanged < $configChanged || $cacheChanged < $specChanged) { $this->spec = yaml_parse_file($this->specFile); foreach ($this->mutators as $mutator) { $mutator->apply($this->config, $this->version); } $data = yaml_emit($this->spec, YAML_UTF8_ENCODING); if (!file_put_contents($this->cacheFile, $data)) { $response->sendFile($this->specFile, ['Content-Type' => 'text/plain;charset=utf-8'], null, $data); return; } } $response->sendFile($this->cacheFile, ['Content-Type' => 'text/plain;charset=utf-8']); }