Completed
Push — master ( 52b06e...08177a )
by
unknown
04:10 queued 10s
created

ThumbnailCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 21 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\MediaBundle\DependencyInjection\Compiler;
15
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Reference;
19
20
class ThumbnailCompilerPass implements CompilerPassInterface
21
{
22
    public function process(ContainerBuilder $container)
23
    {
24
        if (!$container->hasDefinition('sonata.media.thumbnail.format')) {
25
            return;
26
        }
27
28
        $definition = $container->getDefinition(
29
            'sonata.media.thumbnail.format'
30
        );
31
32
        $taggedServices = $container->findTaggedServiceIds(
33
            'sonata.media.resizer'
34
        );
35
36
        foreach ($taggedServices as $id => $tags) {
37
            $definition->addMethodCall(
38
                'addResizer',
39
                [$id, new Reference($id)]
40
            );
41
        }
42
    }
43
}
44