Completed
Pull Request — master (#10)
by Tomáš
02:51
created

DefaultKernel::getKernelParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
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\Bundle\SculpinBundle\HttpKernel;
13
14
use Symplify\PHP7_Sculpin\Bundle\MarkdownBundle\SculpinMarkdownBundle;
15
use Symplify\PHP7_Sculpin\Bundle\MarkdownTwigCompatBundle\SculpinMarkdownTwigCompatBundle;
16
use Symplify\PHP7_Sculpin\Bundle\PaginationBundle\SculpinPaginationBundle;
17
use Symplify\PHP7_Sculpin\Bundle\PostsBundle\SculpinPostsBundle;
18
use Symplify\PHP7_Sculpin\Bundle\SculpinBundle\SculpinBundle;
19
use Symplify\PHP7_Sculpin\Bundle\TwigBundle\SculpinTwigBundle;
20
use Symfony\Component\Config\FileLocator;
21
use Symfony\Component\Config\Loader\LoaderInterface;
22
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
23
use Symfony\Component\HttpKernel\Kernel;
24
use Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle;
25
26
final class DefaultKernel extends Kernel
27
{
28
    /**
29
     * @var string
30
     */
31
    private $projectDir;
32
33
    public function __construct(string $projectDir)
34
    {
35
        $this->projectDir = $projectDir;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function getKernelParameters()
42
    {
43
        return array_merge(parent::getKernelParameters(), [
44
            'sculpin.project_dir' => $this->projectDir,
45
        ]);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function registerBundles()
52
    {
53
        $bundles = [
54
            new SymplifyDefaultAutowireBundle(),
55
            new SculpinMarkdownBundle(),
56
            new SculpinMarkdownTwigCompatBundle(),
57
            new SculpinBundle(),
58
            new SculpinTwigBundle(),
59
            new SculpinPostsBundle(),
60
        ];
61
62
        return $bundles;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function registerContainerConfiguration(LoaderInterface $loader)
69
    {
70
        if (file_exists($file = $this->rootDir.'/config/sculpin_kernel.yml')) {
71
            $loader->load($file);
72
        }
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function boot()
79
    {
80
        if (true === $this->booted) {
81
            return;
82
        }
83
84
        parent::boot();
85
86
        $this->container->compile();
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    protected function buildContainer()
93
    {
94
        $container = $this->getContainerBuilder();
95
        $container->addObjectResource($this);
96
        $this->prepareContainer($container);
97
98
        return $container;
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    protected function initializeContainer()
105
    {
106
        $container = $this->buildContainer();
107
        $container->set('kernel', $this);
108
        $this->container = $container;
109
    }
110
}
111