Completed
Pull Request — master (#10)
by Tomáš
03:17
created

DefaultKernel   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 9

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 9
lcom 4
cbo 9
dl 0
loc 85
ccs 0
cts 49
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getKernelParameters() 0 6 1
A registerBundles() 0 13 1
A registerContainerConfiguration() 0 6 2
A boot() 0 10 2
A buildContainer() 0 8 1
A initializeContainer() 0 6 1
1
<?php
2
3
/*
4
 * This file is a part of Sculpin.
5
 *
6
 * (c) Dragonfly Development Inc.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Symplify\PHP7_Sculpin\SculpinBundle\HttpKernel;
13
14
use Symplify\PHP7_Sculpin\MarkdownBundle\SculpinMarkdownBundle;
15
use Symplify\PHP7_Sculpin\MarkdownTwigCompatBundle\SculpinMarkdownTwigCompatBundle;
16
use Symplify\PHP7_Sculpin\PostsBundle\SculpinPostsBundle;
17
use Symplify\PHP7_Sculpin\SculpinBundle\SculpinBundle;
18
use Symplify\PHP7_Sculpin\TwigBundle\SculpinTwigBundle;
19
use Symfony\Component\Config\Loader\LoaderInterface;
20
use Symfony\Component\HttpKernel\Kernel;
21
use Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle;
22
23
final class DefaultKernel extends Kernel
24
{
25
    /**
26
     * @var string
27
     */
28
    private $projectDir;
29
30
    public function __construct(string $projectDir)
31
    {
32
        $this->projectDir = $projectDir;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function getKernelParameters()
39
    {
40
        return array_merge(parent::getKernelParameters(), [
41
            'sculpin.project_dir' => $this->projectDir,
42
        ]);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function registerBundles()
49
    {
50
        $bundles = [
51
            new SymplifyDefaultAutowireBundle(),
52
            new SculpinMarkdownBundle(),
53
            new SculpinMarkdownTwigCompatBundle(),
54
            new SculpinBundle(),
55
            new SculpinTwigBundle(),
56
            new SculpinPostsBundle(),
57
        ];
58
59
        return $bundles;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function registerContainerConfiguration(LoaderInterface $loader)
66
    {
67
        if (file_exists($file = $this->rootDir.'/config/sculpin_kernel.yml')) {
68
            $loader->load($file);
69
        }
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function boot()
76
    {
77
        if (true === $this->booted) {
78
            return;
79
        }
80
81
        parent::boot();
82
83
        $this->container->compile();
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    protected function buildContainer()
90
    {
91
        $container = $this->getContainerBuilder();
92
        $container->addObjectResource($this);
93
        $this->prepareContainer($container);
94
95
        return $container;
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    protected function initializeContainer()
102
    {
103
        $container = $this->buildContainer();
104
        $container->set('kernel', $this);
105
        $this->container = $container;
106
    }
107
}
108