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

tito10047 / progressive-image-bundle / 22202319160

19 Feb 2026 10:13PM UTC coverage: 90.204% (-0.07%) from 90.276%
22202319160

Pull #10

github

web-flow
Merge e81d12ee5 into 142ac29cb
Pull Request #10: add support for avif format

0 of 16 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

884 of 980 relevant lines covered (90.2%)

340.36 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\RequestStack;
19
use Symfony\Component\HttpFoundation\UriSigner;
20
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
21
use Symfony\Contracts\Cache\TagAwareCacheInterface;
22
use Tito10047\ProgressiveImageBundle\Service\LiipImagineRuntimeConfigGeneratorInterface;
23
use Liip\ImagineBundle\Service\FormatNegotiator;
24

25
final class LiipImagineResponsiveImageUrlGenerator implements ResponsiveImageUrlGeneratorInterface
26
{
27
    public function __construct(
28
        private readonly CacheManager $cacheManager,
29
        private readonly UrlGeneratorInterface $router,
30
        private readonly UriSigner $uriSigner,
31
        private readonly LiipImagineRuntimeConfigGeneratorInterface $runtimeConfigGenerator,
32
        private readonly FilterConfiguration $filterConfiguration,
33
        private readonly RequestStack $requestStack,
34
        private readonly ?TagAwareCacheInterface $cache,
35
        private readonly ?FormatNegotiator $formatNegotiator = null,
36
        private readonly array $alternativeFormats = [],
37
    ) {
38
    }
574✔
39

40
    public function generateUrl(string $path, int $targetW, ?int $targetH = null, ?string $pointInterest = null, array $context = []): string
41
    {
42
        $targetH = $targetH ?? $targetW;
406✔
43
        $filter = $context['filter'] ?? null;
406✔
44
        $result = $this->runtimeConfigGenerator->generate($targetW, $targetH, $filter, $pointInterest, null, null, $context);
406✔
45
        $filterName = $result['filterName'];
406✔
46
        $config = $result['config'];
406✔
47

48
        // Register runtime filter so LiipImagine can find it
49
        try {
50
            $this->filterConfiguration->get($filterName);
406✔
51
        } catch (NonExistingFilterException) {
364✔
52
            $this->filterConfiguration->set($filterName, $config);
364✔
53
        }
54

55
        // Try to return already stored alternative format matching current request preferences
NEW
56
        $request = $this->requestStack->getCurrentRequest();
406✔
NEW
57
        if (null !== $request && null !== $this->formatNegotiator) {
406✔
NEW
58
            $supported = $this->formatNegotiator->negotiate($request, $this->alternativeFormats);
14✔
NEW
59
            foreach ($supported as $format) {
14✔
NEW
60
                $altPath = $path.'.'.$format;
14✔
NEW
61
                if ($this->cacheManager->isStored($altPath, $filterName)) {
14✔
NEW
62
                    return $this->cacheManager->resolve($altPath, $filterName);
14✔
63
                }
64
            }
65
        }
66

NEW
67
        if ($this->cacheManager->isStored($path, $filterName)) {
406✔
NEW
68
            return $this->cacheManager->resolve($path, $filterName);
140✔
69
        }
70

71
        $this->cache?->invalidateTags(['pgi_tag_'.md5($path)]);
294✔
72

73
        $params = [
294✔
74
            'path' => $path,
294✔
75
            'width' => $targetW,
294✔
76
            'height' => $targetH,
294✔
77
            'filter' => $filter,
294✔
78
            'pointInterest' => $pointInterest,
294✔
79
        ];
294✔
80
        $params = array_merge($params, $context);
294✔
81

82
        $url = $this->router->generate('progressive_image_filter', array_filter($params), UrlGeneratorInterface::ABSOLUTE_URL);
294✔
83

84
        return $this->uriSigner->sign($url);
294✔
85
    }
86

87
}
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