Test Setup Failed
Push — dependabot/composer/thomaspark... ( 7e28e7...04472a )
by
unknown
37:44 queued 28:26
created

Kernel::configureContainer()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
15
use Zikula\Bundle\CoreBundle\Helper\PersistedBundleHelper;
16
use Zikula\Bundle\CoreBundle\HttpKernel\ZikulaKernel;
17
18
class Kernel extends ZikulaKernel
19
{
20
    use MicroKernelTrait;
0 ignored issues
show
Bug introduced by
The trait Symfony\Bundle\Framework...Kernel\MicroKernelTrait requires the property $instanceof which is not provided by Kernel.
Loading history...
21
22
    /**
23
     * @var string
24
     */
25
    private $databaseUrl;
26
27
    public function __construct(string $environment, bool $debug, string $databaseUrl = '')
28
    {
29
        parent::__construct($environment, $debug);
30
31
        $this->databaseUrl = $databaseUrl;
32
    }
33
34
    public function registerBundles(): iterable
35
    {
36
        $bundleHelper = new PersistedBundleHelper($this->databaseUrl);
37
        $bundles = require $this->getProjectDir() . '/config/bundles.php';
38
        $bundleHelper->getPersistedBundles($this, $bundles);
39
40
        foreach ($bundles as $class => $envs) {
41
            if ($envs[$this->environment] ?? $envs['all'] ?? false) {
42
                yield new $class();
43
            }
44
        }
45
    }
46
47
    public function getProjectDir(): string
48
    {
49
        return dirname(__DIR__);
50
    }
51
}
52