Completed
Push — master ( 5bda77...cb2c73 )
by Aleh
10s
created

Application::getContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Padawan\Framework;
4
5
use DI\Container;
6
use DI\ContainerBuilder;
7
use Symfony\Component\Console\Application as BaseApplication;
8
9
define("PADAWAN_VERSION", "0.3");
10
define("STUBS_DIR", dirname(dirname(dirname(__DIR__))) . '/stubs');
11
12
/**
13
 * Class Application
14
 */
15
abstract class Application extends BaseApplication
16
{
17
    public function __construct($name = "Padawan")
18
    {
19
        parent::__construct($name, PADAWAN_VERSION);
20
        $this->createContainer();
21
        $this->setAutoExit(false);
22
        $this->loadCommands();
23
    }
24
25
    public function getContainer()
26
    {
27
        return $this->container;
28
    }
29
30
    abstract protected function loadCommands();
31
32
    private function createContainer()
33
    {
34
        $builder = new ContainerBuilder;
35
        $builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache);
36
        $builder->addDefinitions(__DIR__ . '/DI/config.php');
37
        $this->container = $builder->build();
38
    }
39
40
    /** @var Container */
41
    protected $container;
42
}
43