/** * Returns sizes array for photo identified by Flickr photo id * * @param int $photoId * @return array Array of photo size information */ public function getSizes($photoId) { $sizes = $this->adapter->getItem($photoId); if (is_null($sizes)) { $sizes = $this->flickr->getSizes($photoId); $this->adapter->addItem($photoId, $sizes); } return $sizes; }
/** * @param string $request Request uri * @throws \RuntimeException * @return \Zend\Http\PhpEnvironment\Response */ public function dispatch($request) { if (!$this->getResolver()) { throw new \RuntimeException("No resolver setted"); } $asset = $this->resolver->resolve($request); $content = null; $responseCode = 404; $headers = Headers::fromString("Content-Type: text/plain"); if ($asset) { $headers = $this->getHeaders($asset->getFile(), $asset->getMime()); if ($this->browserCached($asset->getFile())) { $responseCode = 304; $headers->addHeader(Connection::fromString("Connection: close")); } else { $responseCode = 200; $cacheKey = "assets-cache-" . md5($request); if ($this->cache) { $content = $this->cache->getItem($cacheKey); } if (!$content) { $content = $asset->getContent(); $assetName = end(explode('\\', get_class($asset))); if (array_key_exists($assetName, $this->filters)) { foreach ($this->filters[$assetName] as $filter) { $content = $filter->filter($content); } } if ($this->cache) { $this->cache->addItem($cacheKey, $content); } } } } else { $content = "Asset not found!"; } $response = new Response(); $response->setStatusCode($responseCode); $response->setContent($content); $response->setHeaders($headers); return $response; }
/** * Add an item. * * @param string $key * @param mixed $value * @return bool * @throws Exception\ExceptionInterface * * @triggers addItem.pre(PreEvent) * @triggers addItem.post(PostEvent) * @triggers addItem.exception(ExceptionEvent) */ public function addItem($key, $value) { $options = $this->getOptions(); if ($options->getWritable() && $options->getClearStatCache()) { clearstatcache(); } return parent::addItem($key, $value); }
/** * Add an item. * * Options: * - namespace <string> optional * - The namespace to use (Default: namespace of object) * - tags <array> optional * - An array of tags * * @param string $key * @param mixed $value * @param array $options * @return boolean * @throws Exception\ExceptionInterface * * @triggers addItem.pre(PreEvent) * @triggers addItem.post(PostEvent) * @triggers addItem.exception(ExceptionEvent) */ public function addItem($key, $value, array $options = array()) { $baseOptions = $this->getOptions(); if ($baseOptions->getWritable() && $baseOptions->getClearStatCache()) { clearstatcache(); } return parent::addItem($key, $value, $options); }