Kernel   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 0 6 3
1
<?php
2
3
namespace App;
4
5
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
6
use Symfony\Component\Config\Loader\LoaderInterface;
7
use Symfony\Component\Config\Resource\FileResource;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
10
use Symfony\Component\Routing\RouteCollectionBuilder;
11
12
class Kernel extends BaseKernel
13
{
14
    use MicroKernelTrait;
15
16
    const CONFIG_EXTS = '.{php,xml,yaml,yml}';
17
18
    public function registerBundles()
19
    {
20
        $contents = require $this->getProjectDir().'/config/bundles.php';
21
        foreach ($contents as $class => $envs) {
22
            if ($envs[$this->environment] ?? $envs['all'] ?? false) {
23
                yield new $class();
24
            }
25
        }
26
    }
27
28
    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
29
    {
30
        $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
31
        $container->setParameter('container.dumper.inline_class_loader', true);
32
        $confDir = $this->getProjectDir().'/config';
33
34
        $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
35
        $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
36
        $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
37
        $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
38
    }
39
40
    protected function configureRoutes(RouteCollectionBuilder $routes)
41
    {
42
        $confDir = $this->getProjectDir().'/config';
43
44
        $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
45
        $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
46
        $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
47
    }
48
}
49