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

tito10047 / progressive-image-bundle / 21093331125

17 Jan 2026 11:10AM UTC coverage: 90.436% (-0.5%) from 90.889%
21093331125

push

github

web-flow
Merge pull request #4 from tito10047/responsive-strategy

change rendering stratety from <img> to <picture><source><img> for better responsive strategy

268 of 332 new or added lines in 19 files covered. (80.72%)

5 existing lines in 2 files now uncovered.

851 of 941 relevant lines covered (90.44%)

318.39 hits per line

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

52.38
/src/DependencyInjection/CheckCacheInterfacePass.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

12
namespace Tito10047\ProgressiveImageBundle\DependencyInjection;
13

14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Contracts\Cache\TagAwareCacheInterface;
17

18
final class CheckCacheInterfacePass implements CompilerPassInterface
19
{
20
    public function process(ContainerBuilder $container): void
21
    {
22
        if ($container->hasParameter('progressive_image.image_cache_enabled') && !$container->getParameter('progressive_image.image_cache_enabled')) {
661✔
23
            return;
15✔
24
        }
25

26
        if (!$container->hasAlias('progressive_image.image_cache_service')) {
646✔
27
            return;
×
28
        }
29

30
        $cacheServiceId = (string) $container->getAlias('progressive_image.image_cache_service');
646✔
31
        if (!$container->hasDefinition($cacheServiceId)) {
646✔
32
            return;
×
33
        }
34

35
        $definition = $container->getDefinition($cacheServiceId);
646✔
36

37
        while ($definition->hasTag('container.service_alias')) {
646✔
38
            $tags = $definition->getTag('container.service_alias');
×
39
            $cacheServiceId = $tags[0]['alias'] ?? $cacheServiceId;
×
40
            if (!$container->hasDefinition($cacheServiceId)) {
×
41
                break;
×
42
            }
43
            $definition = $container->getDefinition($cacheServiceId);
×
44
        }
45

46
        // If it's a cache pool defined via FrameworkBundle, Symfony turns it at build time
47
        // into a definition whose class is e.g. Symfony\Component\Cache\Adapter\ArrayAdapter.
48
        // If it has tags enabled, Symfony wraps it in TagAwareAdapter.
49

50
        $class = $container->getParameterBag()->resolveValue($definition->getClass());
646✔
51

52
        // If class is empty, it might be a factory. In that case we try to look at the factory
53
        if (!$class && $definition->getFactory()) {
646✔
54
            // Here it's difficult to determine the factory return type at compile time without executing code
55
        }
56

57
        if ($class && !is_subclass_of($class, TagAwareCacheInterface::class) && TagAwareCacheInterface::class !== $class) {
646✔
NEW
58
            throw new \LogicException(sprintf('Cache service "%1$s" (class: %2$s) must implement TagAwareCacheInterface to be used in ProgressiveImageBundle. Check if you have "tags: true" enabled for this pool in framework.cache configuration and then set it in bundle configuration: progressive_image: { image_cache_service: "%1$s" }. Example pool configuration: framework: { cache: { pools: { %1$s: { adapter: cache.adapter.redis_tag_aware, tags: true } } } }', $cacheServiceId, $class));
×
59
        }
60

61
        // Special check for Symfony cache pools that don't have a class set immediately,
62
        // but we can find out if they are taggable.
63
        if (!$class || 'Symfony\Component\Cache\Adapter\ArrayAdapter' === $class || 'Symfony\Component\Cache\Adapter\FilesystemAdapter' === $class) {
646✔
64
            if (!$definition->hasTag('cache.taggable')) {
×
65
                // If it doesn't have the cache.taggable tag and the class is not TagAware, we throw an error.
66
                // Symfony TagAwareAdapter has the class set to TagAwareAdapter.
NEW
67
                throw new \LogicException(sprintf('Cache service "%1$s" is not "tag aware". Check if you have "tags: true" enabled for this pool in framework.cache configuration and then set it in bundle configuration: progressive_image: { image_cache_service: "%1$s" }. Example pool configuration: framework: { cache: { pools: { %1$s: { adapter: cache.adapter.redis_tag_aware, tags: true } } } }', $cacheServiceId));
×
68
            }
69
        }
70
    }
71
}
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