Kernel   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 51
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCacheDir() 0 4 1
A getLogDir() 0 4 1
A registerBundles() 0 9 4
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\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
9
use Symfony\Component\Routing\RouteCollectionBuilder;
10
11
/**
12
 * @codeCoverageIgnore
13
 */
14
class Kernel extends BaseKernel
15
{
16
    use MicroKernelTrait;
17
18
    const CONFIG_EXTS = '.{php,xml,yaml,yml}';
19
20
    public function getCacheDir()
21
    {
22
        return $this->getProjectDir().'/var/cache/'.$this->environment;
23
    }
24
25
    public function getLogDir()
26
    {
27
        return $this->getProjectDir().'/var/log';
28
    }
29
30
    public function registerBundles()
31
    {
32
        $contents = require $this->getProjectDir().'/config/bundles.php';
33
        foreach ($contents as $class => $envs) {
34
            if (isset($envs['all']) || isset($envs[$this->environment])) {
35
                yield new $class();
36
            }
37
        }
38
    }
39
40
    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
41
    {
42
        $container->setParameter('container.autowiring.strict_mode', true);
43
        $container->setParameter('container.dumper.inline_class_loader', true);
44
        $confDir = $this->getProjectDir().'/config';
45
        $loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob');
46
        if (is_dir($confDir.'/packages/'.$this->environment)) {
47
            $loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
48
        }
49
        $loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob');
50
        $loader->load($confDir.'/services_'.$this->environment.self::CONFIG_EXTS, 'glob');
51
    }
52
53
    protected function configureRoutes(RouteCollectionBuilder $routes)
54
    {
55
        $confDir = $this->getProjectDir().'/config';
56
        if (is_dir($confDir.'/routes/')) {
57
            $routes->import($confDir.'/routes/*'.self::CONFIG_EXTS, '/', 'glob');
58
        }
59
        if (is_dir($confDir.'/routes/'.$this->environment)) {
60
            $routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
61
        }
62
        $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob');
63
    }
64
}
65