Kernel::configureContainer()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the mailserver-admin package.
6
 * (c) Jeffrey Boehm <https://github.com/jeboehm/mailserver-admin>
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace App;
12
13
use App\DependencyInjection\Compiler\AppSecretGeneratorCompilerPass;
14
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
17
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
18
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
19
20
class Kernel extends BaseKernel
21
{
22
    use MicroKernelTrait;
0 ignored issues
show
Bug introduced by
The trait Symfony\Bundle\Framework...Kernel\MicroKernelTrait requires the property $instanceof which is not provided by App\Kernel.
Loading history...
23
24
    protected function configureContainer(ContainerConfigurator $container): void
25
    {
26
        $container->import('../config/{packages}/*.yaml');
27
        $container->import('../config/{packages}/' . $this->environment . '/*.yaml');
28
29
        if (is_file(\dirname(__DIR__) . '/config/services.yaml')) {
30
            $container->import('../config/services.yaml');
31
            $container->import('../config/{services}_' . $this->environment . '.yaml');
32
        } elseif (is_file($path = \dirname(__DIR__) . '/config/services.php')) {
33
            (require $path)($container->withPath($path), $this);
34
        }
35
    }
36
37
    protected function configureRoutes(RoutingConfigurator $routes): void
38
    {
39
        $routes->import('../config/{routes}/' . $this->environment . '/*.yaml');
40
        $routes->import('../config/{routes}/*.yaml');
41
42
        if (is_file(\dirname(__DIR__) . '/config/routes.yaml')) {
43
            $routes->import('../config/routes.yaml');
44
        } elseif (is_file($path = \dirname(__DIR__) . '/config/routes.php')) {
45
            (require $path)($routes->withPath($path), $this);
46
        }
47
    }
48
49
    protected function build(ContainerBuilder $container): void
50
    {
51
        $container->addCompilerPass(new AppSecretGeneratorCompilerPass());
52
    }
53
}
54