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

ThumbnailCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
cc 3
nc 3
nop 1
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