Skip to content

Commit

Permalink
Merge pull request #2643 from acrobat/fix-liip-imagine-incompatibility
Browse files Browse the repository at this point in the history
[MediaBundle] Fix incompatibility with liip/imagine-bundle 2.2+
  • Loading branch information
acrobat committed Mar 17, 2020
2 parents df7aca9 + 5aadbde commit b92c9c8
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/Kunstmaan/MediaBundle/Helper/Imagine/WebPathResolver.php
Expand Up @@ -38,15 +38,21 @@ protected function getFileUrl($path, $filter)
return parent::getFileUrl($path, $filter);
}

protected function getFilePath($path, $filter)
{
$filterConf = $this->filterConfig->get($filter);
$path = $this->changeFileExtension($path, $filterConf['format']);
$fullPath = $this->getFullPath($path, $filter);

return $this->webRoot.'/'.$fullPath;
}

/**
* {@inheritdoc}
*/
public function resolve($path, $filter)
{
return sprintf('%s/%s',
$this->getBaseUrl(),
$this->getFileUrl($path, $filter)
);
return sprintf('%s/%s', $this->getBaseUrl(), $this->getFileUrl($path, $filter));
}

/**
Expand All @@ -66,4 +72,15 @@ private function changeFileExtension($path, $format)

return $path;
}

/**
* Copy from \Liip\ImagineBundle\Imagine\Cache\Resolver\WebPathResolver::getFullPath
*/
private function getFullPath($path, $filter)
{
// crude way of sanitizing URL scheme ("protocol") part
$path = str_replace('://', '---', $path);

return $this->cachePrefix.'/'.$filter.'/'.ltrim($path, '/');
}
}

0 comments on commit b92c9c8

Please sign in to comment.