| @@ 18-44 (lines=27) @@ | ||
| 15 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
| 16 | use Twig\Extension\RuntimeExtensionInterface; |
|
| 17 | ||
| 18 | class FilterRuntime implements RuntimeExtensionInterface |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * @var CacheManager |
|
| 22 | */ |
|
| 23 | private $cache; |
|
| 24 | ||
| 25 | public function __construct(CacheManager $cache) |
|
| 26 | { |
|
| 27 | $this->cache = $cache; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Gets the browser path for the image and filter to apply. |
|
| 32 | * |
|
| 33 | * @param string $path |
|
| 34 | * @param string $filter |
|
| 35 | * @param string|null $resolver |
|
| 36 | * @param int $referenceType |
|
| 37 | * |
|
| 38 | * @return string |
|
| 39 | */ |
|
| 40 | public function filter($path, $filter, array $config = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_URL) |
|
| 41 | { |
|
| 42 | return $this->cache->getBrowserPath(parse_url($path, PHP_URL_PATH), $filter, $config, $resolver, $referenceType); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 22-56 (lines=35) @@ | ||
| 19 | /** |
|
| 20 | * @deprecated |
|
| 21 | */ |
|
| 22 | trait FilterTrait |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @var CacheManager |
|
| 26 | */ |
|
| 27 | private $cache; |
|
| 28 | ||
| 29 | public function __construct(CacheManager $cache) |
|
| 30 | { |
|
| 31 | $this->cache = $cache; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Gets the browser path for the image and filter to apply. |
|
| 36 | * |
|
| 37 | * @param string $path |
|
| 38 | * @param string $filter |
|
| 39 | * @param string|null $resolver |
|
| 40 | * @param int $referenceType |
|
| 41 | * |
|
| 42 | * @return string |
|
| 43 | */ |
|
| 44 | public function filter($path, $filter, array $config = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_URL) |
|
| 45 | { |
|
| 46 | return $this->cache->getBrowserPath(parse_url($path, PHP_URL_PATH), $filter, $config, $resolver, $referenceType); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * {@inheritdoc} |
|
| 51 | */ |
|
| 52 | public function getName() |
|
| 53 | { |
|
| 54 | return 'liip_imagine'; |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||