ConfigCompilerPass::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 1
crap 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
        $locator = new FileLocator([
25 2
            ROOT,
26 2
            ROOT . 'app/',
27
        ]);
28
29 2
        $xmlLoader = new XmlFileLoader($container, $locator);
30 2
        $xmlLoader->import('container.xml');
31
32 2
        $ymlLoader = new YamlFileLoader($container, $locator);
33 2
        $ymlLoader->import('config.yml', null, true);
34
35 2
        $environment = $container->getParameter('environment');
36 2
        $container->setParameter('debug', $environment !== Environment::PRODUCTION);
37 2
    }
38
}
39