public function resolve($path, $filter) { $path = $this->rewritePath($path); $url = $this->resolver->resolve($path, $filter); $url = $this->rewriteUrl($url); return $url; }
/** * {@inheritDoc} */ public function resolve($path, $filter) { $key = $this->generateCacheKey($path, $filter); if ($this->cache->contains($key)) { return $this->cache->fetch($key); } $resolved = $this->resolver->resolve($path, $filter); $this->saveToCache($key, $resolved); return $resolved; }
/** * {@inheritdoc} * * @throws \InvalidArgumentException If field value is not an instance of \eZ\Publish\Core\FieldType\Image\Value. * @throws \eZ\Publish\Core\MVC\Exception\SourceImageNotFoundException If source image cannot be found. * @throws \eZ\Publish\API\Repository\Exceptions\InvalidVariationException If a problem occurs with generated variation. */ public function getVariation(Field $field, VersionInfo $versionInfo, $variationName, array $parameters = array()) { /** @var \eZ\Publish\Core\FieldType\Image\Value $imageValue */ $imageValue = $field->value; $fieldId = $field->id; $fieldDefIdentifier = $field->fieldDefIdentifier; if (!$this->supportsValue($imageValue)) { throw new InvalidArgumentException("Value for field #{$fieldId} ({$fieldDefIdentifier}) cannot be used for image alias generation."); } $originalPath = $imageValue->id; // Create the image alias only if it does not already exist. if ($variationName !== IORepositoryResolver::VARIATION_ORIGINAL && !$this->ioResolver->isStored($originalPath, $variationName)) { try { $originalBinary = $this->dataLoader->find($originalPath); } catch (NotLoadableException $e) { throw new SourceImageNotFoundException($originalPath, 0, $e); } if ($this->logger) { $this->logger->debug("Generating '{$variationName}' variation on {$originalPath}, field #{$fieldId} ({$fieldDefIdentifier})"); } $this->ioResolver->store($this->applyFilter($originalBinary, $variationName), $originalPath, $variationName); } elseif ($this->logger) { $this->logger->debug("'{$variationName}' variation on {$originalPath} is already generated. Loading from cache."); } try { $aliasInfo = new SplFileInfo($this->ioResolver->resolve($originalPath, $variationName)); } catch (NotResolvableException $e) { // If for some reason image alias cannot be resolved, throw the appropriate exception. throw new InvalidVariationException($variationName, 'image', 0, $e); } return new ImageVariation(array('name' => $variationName, 'fileName' => $aliasInfo->getFilename(), 'dirPath' => $aliasInfo->getPath(), 'uri' => $aliasInfo->getPathname(), 'imageId' => $imageValue->imageId)); }
/** * {@inheritDoc} */ public function resolve(Request $request, $path, $filter) { $key = $this->generateCacheKey('resolve', $path, $filter); if ($this->cache->contains($key)) { return $this->cache->fetch($key); } $targetPath = $this->resolver->resolve($request, $path, $filter); $this->saveToCache($key, $targetPath); /* * The targetPath being a string will be forwarded to the ResolverInterface::store method. * As there is no way to reverse this operation by the interface, we store this information manually. * * If it's not a string, it's a Response it will be returned as it without calling the store method. */ if (is_string($targetPath)) { $reverseKey = $this->generateCacheKey('reverse', $targetPath, $filter); $this->saveToCache($reverseKey, $path); } return $targetPath; }
/** * {@inheritdoc} */ public function resolve($path, $filter) { return $this->rewriteUrl($this->resolver->resolve($path, $filter)); }