Kernel   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 0 6 4
A getCacheDir() 0 3 1
A configureContainer() 0 13 1
A configureRoutes() 0 7 1
A getLogDir() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API;
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 getCacheDir()
19
    {
20
        return $this->getProjectDir().'/var/cache/'.$this->environment;
21
    }
22
23
    public function getLogDir()
24
    {
25
        return $this->getProjectDir().'/var/log';
26
    }
27
28
    public function registerBundles()
29
    {
30
        $contents = require $this->getProjectDir().'/config/bundles.php';
31
        foreach ($contents as $class => $envs) {
32
            if (isset($envs['all']) || isset($envs[$this->environment])) {
33
                yield new $class();
34
            }
35
        }
36
    }
37
38
    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
39
    {
40
        $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
41
        // Feel free to remove the "container.autowiring.strict_mode" parameter
42
        // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
43
        $container->setParameter('container.autowiring.strict_mode', true);
44
        $container->setParameter('container.dumper.inline_class_loader', true);
45
        $confDir = $this->getProjectDir().'/config';
46
47
        $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
48
        $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
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
57
        $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
58
        $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
59
        $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
60
    }
61
}
62