Completed
Pull Request — master (#693)
by
unknown
03:28
created

ThumbnailCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 3
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
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 Sonata\MediaBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class ThumbnailCompilerPass implements CompilerPassInterface
19
{
20
    public function process(ContainerBuilder $container)
21
    {
22
        if (!$container->hasDefinition('sonata.media.thumbnail.format')) {
23
            return;
24
        }
25
26
        $definition = $container->getDefinition(
27
            'sonata.media.thumbnail.format'
28
        );
29
30
        $taggedServices = $container->findTaggedServiceIds(
31
            'sonata.media.resizer'
32
        );
33
        foreach ($taggedServices as $id => $tags) {
34
            $definition->addMethodCall(
35
                'addResizer',
36
                array($id, new Reference($id))
37
            );
38
        }
39
    }
40
}
41