Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Kernel
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
4 / 4
7
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
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;
29
30class Kernel extends BaseKernel
31{
32    use MicroKernelTrait;
33
34    public const CONFIG_EXTS = '.{php,xml,yaml,yml}';
35
36    public function getCacheDir(): string
37    {
38        return $this->getProjectDir() . '/var/cache/' . $this->environment;
39    }
40
41    public function getLogDir(): string
42    {
43        return $this->getProjectDir() . '/var/log';
44    }
45
46    public function registerBundles(): iterable
47    {
48        $contents = require $this->getProjectDir() . '/config/bundles.php';
49        foreach ($contents as $class => $envs) {
50            if (isset($envs['all']) || isset($envs[$this->environment])) {
51                yield new $class();
52            }
53        }
54    }
55
56    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
57    {
58        $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
59        // Feel free to remove the "container.autowiring.strict_mode" parameter
60        // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
61        $container->setParameter('container.autowiring.strict_mode', true);
62        $container->setParameter('container.dumper.inline_class_loader', true);
63        $confDir = $this->getProjectDir() . '/config';
64
65        $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
66        $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
67
68        $loader->load($confDir . '/{infrastructure}/orm/*/*' . self::CONFIG_EXTS, 'glob');
69        $loader->load($confDir . '/{infrastructure}/orm/*/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
70
71        // Static parameters
72        $loader->load($confDir . '/{parameters}' . self::CONFIG_EXTS, 'glob');
73
74        $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
75        $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
76    }
77
78    //    protected function configureRoutes(RouteCollectionBuilder $routes)
79    //    {
80    //        $confDir = $this->getProjectDir() . '/config';
81    //
82    //        $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
83    //        $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
84    //        $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
85    //    }
86}