Completed
Push — develop ( 4602a5...e9597c )
by Andreas
07:50
created

App::configureContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.2963

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 1
cts 3
cp 0.3333
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1.2963
1
<?php
2
namespace Wambo\Core;
3
use DI\ContainerBuilder;
4
use Wambo\Core\Module\Module;
5
use Wambo\Core\Module\ModuleRepository;
6
7
/**
8
 * Class App
9
 * @package Wambo\Core
10
 */
11
class App extends \DI\Bridge\Slim\App
12
{
13
    /**
14
     * @var string
15
     */
16
    private $bootstrapFilePath;
17 1
18
    /**
19 1
     * App constructor.
20 1
     *
21 1
     * @param string $bootstrapFilePath
22
     */
23
    public function __construct(string $bootstrapFilePath)
24
    {
25
        $this->bootstrapFilePath = $bootstrapFilePath;
26 1
27
        parent::__construct();
28
        $this->loadModules();
29 1
    }
30
31
    protected function configureContainer(ContainerBuilder $builder)
32 1
    {
33
        $builder->addDefinitions($this->bootstrapFilePath);
34
    }
35
36 1
    /**
37
     * add modules to App
38
     */
39
    private function loadModules()
40
    {
41
        /** @var ModuleRepository $repo */
42
        $repo = $this->getContainer()->get('module_repository');
43
44
        /** @var Module $module */
45
        foreach ($repo->getAll() as $module) {
46
            $moduleClass = $module->getClass();
47
            new $moduleClass($this);
48
        }
49
    }
50
}