MajimaPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 3
1
<?php
2
/**
3
 * Copyright (c) 2017
4
 *
5
 * @package   Majima
6
 * @author    David Neustadt <[email protected]>
7
 * @copyright 2017 David Neustadt
8
 * @license   MIT
9
 */
10
11
namespace Majima\DependencyInjection\Compiler;
12
13
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
16
class MajimaPass implements CompilerPassInterface
17
{
18
    public function process(ContainerBuilder $container)
19
    {
20
        /*
21
         * Register Controllers from controllers service
22
         */
23
        $container->get('majima.controllers')->registerControllers($container);
24
25
        $configPath = BASE_DIR . join(DIRECTORY_SEPARATOR, ['var', 'conf', 'config.json']);
0 ignored issues
show
Bug introduced by
The constant Majima\DependencyInjection\Compiler\BASE_DIR was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
26
27
        if (!file_exists($configPath)) {
28
            return;
29
        }
30
31
        $config = json_decode(file_get_contents($configPath));
32
33
        foreach ($config as $key => $value) {
34
            $container->setParameter($key, $value);
35
        }
36
        $container->setParameter('db_config_loaded', true);
37
    }
38
}