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

ThumbnailCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 3
eloc 11
nc 3
nop 1
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