Passed
Push — master ( 0e1324...59b22d )
by Dev
03:45
created

ImagineWebCacheResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 3 1
A __construct() 0 11 1
1
<?php
2
3
namespace PiedWeb\CMSBundle\Service;
4
5
use Symfony\Component\Filesystem\Filesystem;
6
use Symfony\Component\Routing\RequestContext;
7
8
class ImagineWebCacheResolver extends \Liip\ImagineBundle\Imagine\Cache\Resolver\WebPathResolver //implements ResolverInterface
9
{
10
    public function __construct(
11
        Filesystem $filesystem,
12
        RequestContext $requestContext,
13
        $webRootDir,
14
        $cachePrefix = 'media'
15
    ) {
16
        $this->filesystem = $filesystem;
17
        $this->requestContext = $requestContext;
18
        $this->webRoot = rtrim(str_replace('//', '/', $webRootDir), '/');
19
        $this->cachePrefix = ltrim(str_replace('//', '/', $cachePrefix), '/');
20
        $this->cacheRoot = $this->webRoot.'/'.$this->cachePrefix;
21
    }
22
23
    public function resolve($path, $filter)
24
    {
25
        return '/'.$this->getFileUrl($path, $filter);
26
    }
27
}
28