Completed
Push — master ( 1f2b71...3f1d1d )
by Matze
07:04
created

ConfigCompilerPass   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 1
1
<?php
2
3
namespace BrainExe\Core\DependencyInjection\CompilerPass;
4
5
use BrainExe\Core\Annotations\CompilerPass;
6
use BrainExe\Core\Environment;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
11
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
12
13
/**
14
 * @CompilerPass(priority=10)
15
 */
16
class ConfigCompilerPass implements CompilerPassInterface
17
{
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 2
    public function process(ContainerBuilder $container)
23
    {
24 2
        $container->setParameter('application.root', ROOT);
25
26 2
        $locator = new FileLocator([
27 2
            ROOT,
28 2
            ROOT . 'app/',
29
        ]);
30
31 2
        $xmlLoader = new XmlFileLoader($container, $locator);
32 2
        $xmlLoader->import('container.xml');
33
34 2
        $ymlLoader = new YamlFileLoader($container, $locator);
35 2
        $ymlLoader->import('config.yml', null, true);
36
37 2
        $environment = $container->getParameter('environment');
38 2
        $container->setParameter('debug', $environment !== Environment::PRODUCTION);
39 2
    }
40
}
41