for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Liip\ImagineBundle\Templating;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
trait FilterTrait
{
/**
* @var CacheManager
private $cache;
public function __construct(CacheManager $cache)
$this->cache = $cache;
}
* Gets the browser path for the image and filter to apply.
public function filter(
string $path,
string $filter,
array $config = [],
?string $resolver = null,
int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL
): string {
$path = parse_url($path, PHP_URL_PATH);
return $this->cache->getBrowserPath($path, $filter, $config, $resolver, $referenceType);
* Gets the cache path for the image and filter to apply.
public function filterCache(
?string $resolver = null
if (!empty($config)) {
$path = $this->cache->getRuntimePath($path, $config);
return $this->cache->resolve($path, $filter, $resolver);
* {@inheritdoc}
public function getName(): string
return 'liip_imagine';