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

tito10047 / progressive-image-bundle / 22202243069

19 Feb 2026 10:11PM UTC coverage: 75.816% (-14.5%) from 90.276%
22202243069

Pull #10

github

web-flow
Merge 7c6c5a0cf 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.

743 of 980 relevant lines covered (75.82%)

9.74 hits per line

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

0.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
    }
×
39

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

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

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

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

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

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

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

84
        return $this->uriSigner->sign($url);
×
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