Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
Kernel
100.00% covered (success)
100.00%
21 / 21
100.00% covered (success)
100.00%
5 / 5
8
100.00% covered (success)
100.00%
1 / 1
 getCacheDir
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLogDir
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 registerBundles
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
4
 configureContainer
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
 configureRoutes
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * This file is part of the MADIS - RGPD Management application.
5 *
6 * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22namespace App;
23
24use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
25use Symfony\Component\Config\Loader\LoaderInterface;
26use Symfony\Component\Config\Resource\FileResource;
27use Symfony\Component\DependencyInjection\ContainerBuilder;
28use Symfony\Component\HttpKernel\Kernel as BaseKernel;
29use Symfony\Component\Routing\RouteCollectionBuilder;
30
31class Kernel extends BaseKernel
32{
33    use MicroKernelTrait;
34
35    public const CONFIG_EXTS = '.{php,xml,yaml,yml}';
36
37    public function getCacheDir()
38    {
39        return $this->getProjectDir() . '/var/cache/' . $this->environment;
40    }
41
42    public function getLogDir()
43    {
44        return $this->getProjectDir() . '/var/log';
45    }
46
47    public function registerBundles()
48    {
49        $contents = require $this->getProjectDir() . '/config/bundles.php';
50        foreach ($contents as $class => $envs) {
51            if (isset($envs['all']) || isset($envs[$this->environment])) {
52                yield new $class();
53            }
54        }
55    }
56
57    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
58    {
59        $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
60        // Feel free to remove the "container.autowiring.strict_mode" parameter
61        // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
62        $container->setParameter('container.autowiring.strict_mode', true);
63        $container->setParameter('container.dumper.inline_class_loader', true);
64        $confDir = $this->getProjectDir() . '/config';
65
66        $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
67        $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
68
69        $loader->load($confDir . '/{infrastructure}/orm/*/*' . self::CONFIG_EXTS, 'glob');
70        $loader->load($confDir . '/{infrastructure}/orm/*/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
71
72        // Static parameters
73        $loader->load($confDir . '/{parameters}' . self::CONFIG_EXTS, 'glob');
74
75        $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
76        $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
77    }
78
79    protected function configureRoutes(RouteCollectionBuilder $routes)
80    {
81        $confDir = $this->getProjectDir() . '/config';
82
83        $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
84        $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
85        $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
86    }
87}