eZ\Bundle\EzPublishCoreBundle\Imagine\IORepositoryResolver::resolve PHP Method

resolve() public method

public resolve ( $path, $filter )
    public function resolve($path, $filter)
    {
        try {
            $binaryFile = $this->ioService->loadBinaryFile($path);
            // Treat a MissingBinaryFile as a not loadable file.
            if ($binaryFile instanceof MissingBinaryFile) {
                throw new NotResolvableException("Variation image not found in {$path}");
            }
            if ($filter !== static::VARIATION_ORIGINAL) {
                $variationPath = $this->getFilePath($path, $filter);
                $variationBinaryFile = $this->ioService->loadBinaryFile($variationPath);
                $path = $variationBinaryFile->uri;
            } else {
                $path = $binaryFile->uri;
            }
            return sprintf('%s%s', $path[0] === '/' ? $this->getBaseUrl() : '', $path);
        } catch (NotFoundException $e) {
            throw new NotResolvableException("Variation image not found in {$path}", 0, $e);
        }
    }

Usage Example

 /**
  * @dataProvider resolveProvider
  */
 public function testResolve($path, $filter, $requestUrl, $expected)
 {
     if ($requestUrl) {
         $this->requestContext->fromRequest(Request::create($requestUrl));
     }
     $storageDir = '/var/doctorwho/storage/images';
     $this->ioService->expects($this->once())->method('loadBinaryFile')->with($path)->will($this->returnValue(new BinaryFile(array('uri' => "{$storageDir}/{$path}"))));
     $result = $this->imageResolver->resolve($path, $filter);
     $this->assertSame($expected, $result);
 }
All Usage Examples Of eZ\Bundle\EzPublishCoreBundle\Imagine\IORepositoryResolver::resolve