Completed
Push — master ( 5472e0...10da27 )
by Eric
18:09 queued 11:39
created

ConfigureFactoryPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 3
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Bundle\TranslationBundle\DependencyInjection\Compiler;
13
14
use Lug\Component\Translation\Factory\TranslatableFactory;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/**
20
 * @author GeLo <[email protected]>
21
 */
22
class ConfigureFactoryPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 2
    public function process(ContainerBuilder $container)
28
    {
29 2
        foreach ($container->findTaggedServiceIds('lug.factory') as $service => $attributes) {
30 2
            $factory = $container->getDefinition($service);
31
32 2
            if (is_a($factory->getClass(), TranslatableFactory::class, true)) {
33 1
                $factory->addArgument(new Reference('lug.translation.context.locale'));
34 1
            }
35 2
        }
36 2
    }
37
}
38