• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tito10047 / progressive-image-bundle / 20675022582

03 Jan 2026 08:51AM UTC coverage: 86.782%. Remained the same
20675022582

push

github

tito10047
update copyright in LICENSE.md

604 of 696 relevant lines covered (86.78%)

175.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/UrlGenerator/LiipImagineResponsiveImageUrlGenerator.php
1
<?php
2

3
/*
4
 * This file is part of the Progressive Image Bundle.
5
 *
6
 * (c) Jozef Môstka <https://github.com/tito10047/progressive-image-bundle>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
declare(strict_types=1);
12

13
namespace Tito10047\ProgressiveImageBundle\UrlGenerator;
14

15
use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException;
16
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
17
use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration;
18
use Symfony\Component\HttpFoundation\UriSigner;
19
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
20
use Symfony\Contracts\Cache\TagAwareCacheInterface;
21
use Tito10047\ProgressiveImageBundle\Service\LiipImagineRuntimeConfigGeneratorInterface;
22

23
final class LiipImagineResponsiveImageUrlGenerator implements ResponsiveImageUrlGeneratorInterface
24
{
25
        public function __construct(
26
                private readonly CacheManager $cacheManager,
27
                private readonly UrlGeneratorInterface $router,
28
                private readonly UriSigner $uriSigner,
29
                private readonly LiipImagineRuntimeConfigGeneratorInterface $runtimeConfigGenerator,
30
                private readonly FilterConfiguration $filterConfiguration,
31
                private readonly ?TagAwareCacheInterface $cache,
32
                private readonly ?string $filter = null,
33
        ) {
34
        }
266✔
35

36
        public function generateUrl(string $path, int $targetW, ?int $targetH, ?string $pointInterest = null): string
37
        {
38
                $targetH = $targetH ?? $targetW;
140✔
39
                $result = $this->runtimeConfigGenerator->generate($targetW, $targetH, $this->filter, $pointInterest);
140✔
40
                $filterName = $result['filterName'];
140✔
41
                $config = $result['config'];
140✔
42

43
                // Register runtime filter so LiipImagine can find it
44
                try {
45
                        $this->filterConfiguration->get($filterName);
140✔
46
                } catch (NonExistingFilterException) {
112✔
47
                        $this->filterConfiguration->set($filterName, $config);
112✔
48
                }
49

50
                if ($this->cacheManager->isStored($path, $filterName)) {
140✔
51
                        return $this->cacheManager->getBrowserPath($path, $filterName);
28✔
52
                }
53

54
                $this->cache?->invalidateTags(['pgi_tag_' . md5($path)]);
112✔
55

56
                $url = $this->router->generate('progressive_image_filter', [
112✔
57
                        'path' => $path,
112✔
58
                        'width' => $targetW,
112✔
59
                        'height' => $targetH,
112✔
60
                        'filter' => $this->filter,
112✔
61
                        'pointInterest' => $pointInterest,
112✔
62
                ], UrlGeneratorInterface::ABSOLUTE_URL);
112✔
63

64
                return $this->uriSigner->sign($url);
112✔
65
        }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc