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

tito10047 / progressive-image-bundle / 20661725623

02 Jan 2026 04:11PM UTC coverage: 89.065%. Remained the same
20661725623

push

github

tito10047
replace `grid` with `sizes`: update all references in templates, tests, and documentation to align with the new attribute name; adjust `Image` component logic accordingly and ensure backward compatibility

1 of 1 new or added line in 1 file covered. (100.0%)

111 existing lines in 9 files now uncovered.

562 of 631 relevant lines covered (89.06%)

166.02 hits per line

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

64.29
/src/Controller/LiipImagineController.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tito10047\ProgressiveImageBundle\Controller;
6

7
use Tito10047\ProgressiveImageBundle\Service\LiipImagineRuntimeConfigGenerator;
8
use Tito10047\ProgressiveImageBundle\Service\MetadataReader;
9
use Liip\ImagineBundle\Config\Controller\ControllerConfig;
10
use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException;
11
use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException;
12
use Liip\ImagineBundle\Imagine\Cache\Helper\PathHelper;
13
use Liip\ImagineBundle\Imagine\Data\DataManager;
14
use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration;
15
use Liip\ImagineBundle\Service\FilterService;
16
use Symfony\Component\HttpFoundation\RedirectResponse;
17
use Symfony\Component\HttpFoundation\Request;
18
use Symfony\Component\HttpFoundation\Response;
19
use Symfony\Component\HttpFoundation\UriSigner;
20
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
21
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
22
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
23

24
class LiipImagineController
25
{
26
        public function __construct(
27
                private readonly UriSigner  $signer,
28
                private readonly FilterService $filterService,
29
                private readonly DataManager $dataManager,
30
                private readonly FilterConfiguration $filterConfiguration,
31
                private readonly ControllerConfig $controllerConfig,
32
                private readonly LiipImagineRuntimeConfigGenerator $runtimeConfigGenerator,
33
                private readonly MetadataReader $metadataReader,
34
        ) {
UNCOV
35
        }
70✔
36

37
        public function index(
38
                Request $request,
39
                #[MapQueryParameter] string $path,
40
                #[MapQueryParameter] int $width,
41
                #[MapQueryParameter] int $height,
42
                #[MapQueryParameter] ?string $filter = null,
43
                #[MapQueryParameter] ?string $pointInterest = null,
44
        ): Response {
UNCOV
45
                $path = PathHelper::urlPathToFilePath($path);
70✔
46

UNCOV
47
                $origWidth = null;
70✔
UNCOV
48
                $origHeight = null;
70✔
UNCOV
49
                if ($pointInterest) {
70✔
UNCOV
50
                        $metadata = $this->metadataReader->getMetadata($path);
28✔
UNCOV
51
                        if ($metadata) {
28✔
UNCOV
52
                                $origWidth = $metadata->width;
28✔
UNCOV
53
                                $origHeight = $metadata->height;
28✔
54
                        }
55
                }
56

UNCOV
57
                $result = $this->runtimeConfigGenerator->generate($width, $height, $filter, $pointInterest, $origWidth, $origHeight);
70✔
UNCOV
58
                $filterName = $result['filterName'];
70✔
UNCOV
59
                $config = $result['config'];
70✔
60

UNCOV
61
                $this->filterConfiguration->set($filterName, $config);
70✔
62

UNCOV
63
                if (true !== $this->signer->checkRequest($request)) {
70✔
64
                        throw new BadRequestHttpException(\sprintf('Signed url does not pass the sign check for path "%s" and filter "%s"', $path, $filter));
×
65
                }
66

UNCOV
67
                return $this->createRedirectResponse(function () use ($path, $filterName, $request) {
70✔
UNCOV
68
                        return $this->filterService->getUrlOfFilteredImage($path, $filterName);
70✔
UNCOV
69
                }, $path, $filterName);
70✔
70
        }
71

72
        private function createRedirectResponse(\Closure $url, string $path, string $filter): RedirectResponse
73
        {
74
                try {
UNCOV
75
                        return new RedirectResponse($url(), $this->controllerConfig->getRedirectResponseCode());
70✔
76
                } catch (NotLoadableException $exception) {
×
77
                        if (null !== $this->dataManager->getDefaultImageUrl($filter)) {
×
78
                                return new RedirectResponse($this->dataManager->getDefaultImageUrl($filter));
×
79
                        }
80

81
                        throw new NotFoundHttpException(\sprintf('Source image for path "%s" could not be found', $path), $exception);
×
82
                } catch (NonExistingFilterException $exception) {
×
83
                        throw new NotFoundHttpException(\sprintf('Requested non-existing filter "%s"', $filter), $exception);
×
84
                } catch (\RuntimeException $exception) {
×
85
                        throw new \RuntimeException(\sprintf('Unable to create image for path "%s" and filter "%s". Message was "%s"', $path, $filter, $exception->getMessage()), 0, $exception);
×
86
                }
87
        }
88

89
        private function isWebpSupported(Request $request): bool
90
        {
91
                return false !== mb_stripos($request->headers->get('accept', ''), 'image/webp');
×
92
        }
93
}
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