Completed
Push — master ( 10d8a3...77db4f )
by Beñat
05:15
created

TwigPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 3
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\FileBundle\DependencyInjection\Compiler;
14
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
/**
19
 * Register Twig services compiler pass.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
class TwigPass implements CompilerPassInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function process(ContainerBuilder $container)
29
    {
30
        if (!$container->hasDefinition('bengor_file.file_bundle.twig.download_extension')) {
31
            return;
32
        }
33
34
        $config = $container->getParameter('bengor_file.config');
35
36
        $handlers = [];
37
        foreach ($config['file_class'] as $key => $file) {
38
            $handlers[$key] = $container->getDefinition('bengor.file.application.query.' . $key . '_of_id');
39
        }
40
41
        $container->getDefinition('bengor_file.file_bundle.twig.download_extension')->replaceArgument(
42
            1,
43
            $handlers
44
        );
45
    }
46
}
47