public function serve($services) { $services = $this->parse($services); if (empty($services)) { throw new Exception('No service selected'); } $key = 'asset-' . implode('-', $services); $cache = new Cache($key, $this->expire); if (($content = $cache->load()) === false) { foreach ($services as $srv) { $content .= $this->getContent($srv); } if ($this->config['psx_debug'] !== true) { $cache->write($content); } } header('Content-type: ' . $this->provider->getContentType()); return $content; }
/** * @httpMethod GET * @path /{service} * @nickname getApiDetails * @responseClass Declaration */ public function getApiDetails() { try { $basePath = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api'; $serviceName = strtolower($this->getUriFragments('service')); $cache = new Cache('swagger-api-detail-' . $serviceName); if (($declaration = $cache->load()) === false) { $declaration = new Declaration(Base::getVersion(), $basePath, null); $this->buildApiDetails($declaration, $serviceName); $cache->write(serialize($declaration)); } else { $declaration = unserialize($declaration); } $this->setResponse($declaration); } catch (\Exception $e) { $msg = new Message($e->getMessage(), false); $this->setResponse($msg); } }
public function getInlineContent() { $key = 'gadget-' . $this->id; $expire = (int) $this->expire; $cache = new Cache($key, $expire); if ($this->cache == 0 || ($content = $cache->load()) === false) { $content = $this->executeContent(); // if caching is enabled write the cache if ($this->cache == 1) { $cache->write($content); } } return $content; }