Test Setup Failed
Push — symfony-upgrade ( 8f42b6...acd450 )
by MusikAnimal
05:33
created

Kernel   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
dl 0
loc 47
rs 10
c 1
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A configureRoutes() 0 7 1
A registerBundles() 0 6 3
A configureContainer() 0 11 2
A getProjectDir() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace App;
6
7
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
8
use Symfony\Component\Config\Loader\LoaderInterface;
9
use Symfony\Component\Config\Resource\FileResource;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
12
use Symfony\Component\Routing\RouteCollectionBuilder;
13
14
/**
15
 * Class Kernel. Generated by Symfony.
16
 */
17
class Kernel extends BaseKernel
18
{
19
    use MicroKernelTrait;
20
21
    private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
22
23
    public function __construct(string $environment, bool $debug)
24
    {
25
        date_default_timezone_set('UTC');
26
        parent::__construct($environment, $debug);
27
    }
28
29
    public function registerBundles(): iterable
30
    {
31
        $contents = require $this->getProjectDir().'/config/bundles.php';
32
        foreach ($contents as $class => $envs) {
33
            if ($envs[$this->environment] ?? $envs['all'] ?? false) {
34
                yield new $class();
35
            }
36
        }
37
    }
38
39
    public function getProjectDir(): string
40
    {
41
        return \dirname(__DIR__);
42
    }
43
44
    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
45
    {
46
        $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
47
        $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug);
48
        $container->setParameter('container.dumper.inline_factories', true);
49
        $confDir = $this->getProjectDir().'/config';
50
51
        $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
52
        $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
53
        $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
54
        $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
55
    }
56
57
    protected function configureRoutes(RouteCollectionBuilder $routes): void
58
    {
59
        $confDir = $this->getProjectDir().'/config';
60
61
        $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob');
62
        $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
63
        $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
64
    }
65
}
66