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

tito10047 / progressive-image-bundle / 31772562749

14 Aug 2026 05:17AM UTC coverage: 90.385%. Remained the same
31772562749

push

github

Jozef Mostka
update docs

0 of 2 new or added lines in 1 file covered. (0.0%)

893 of 988 relevant lines covered (90.38%)

392.31 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')) {
854 ✔
23
            return;
17 ✔
24
        }
25

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

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

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

37
        while ($definition->hasTag('container.service_alias')) {
837 ✔
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());
837 ✔
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()) {
837 ✔
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) {
837 ✔
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: 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) {
837 ✔
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: tags: true } } } }', $cacheServiceId));
×
68
            }
69
        }
70
    }
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc