Completed
Push — 3.x ( eebc20...445039 )
by Grégoire
04:15
created

AppKernel   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 13

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 13
dl 0
loc 68
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A registerBundles() 0 13 1
A getCacheDir() 0 4 1
A getLogDir() 0 4 1
A getProjectDir() 0 4 1
A configureRoutes() 0 4 1
A configureContainer() 0 19 1
A getBaseDir() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\AdminBundle\Tests\App;
15
16
use Knp\Bundle\MenuBundle\KnpMenuBundle;
17
use Sonata\AdminBundle\SonataAdminBundle;
18
use Sonata\BlockBundle\SonataBlockBundle;
19
use Sonata\CoreBundle\SonataCoreBundle;
20
use Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle;
21
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
22
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
23
use Symfony\Bundle\SecurityBundle\SecurityBundle;
24
use Symfony\Bundle\TwigBundle\TwigBundle;
25
use Symfony\Component\Config\Loader\LoaderInterface;
26
use Symfony\Component\DependencyInjection\ContainerBuilder;
27
use Symfony\Component\HttpKernel\Kernel;
28
use Symfony\Component\Routing\RouteCollectionBuilder;
29
30
final class AppKernel extends Kernel
31
{
32
    use MicroKernelTrait;
33
34
    public function __construct()
35
    {
36
        parent::__construct('test', false);
37
    }
38
39
    public function registerBundles()
40
    {
41
        return [
42
            new FrameworkBundle(),
43
            new TwigBundle(),
44
            new SecurityBundle(),
45
            new KnpMenuBundle(),
46
            new SonataBlockBundle(),
47
            new SonataCoreBundle(),
48
            new SonataDoctrineBundle(),
49
            new SonataAdminBundle(),
50
        ];
51
    }
52
53
    public function getCacheDir(): string
54
    {
55
        return $this->getBaseDir().'cache';
56
    }
57
58
    public function getLogDir(): string
59
    {
60
        return $this->getBaseDir().'log';
61
    }
62
63
    public function getProjectDir()
64
    {
65
        return __DIR__;
66
    }
67
68
    protected function configureRoutes(RouteCollectionBuilder $routes)
69
    {
70
        $routes->import($this->getProjectDir().'/config/routes.yml');
71
    }
72
73
    protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader)
74
    {
75
        $containerBuilder->loadFromExtension('framework', [
76
            'secret' => 'MySecret',
77
            'trusted_proxies' => [],
78
            'fragments' => ['enabled' => true],
79
            'form' => ['enabled' => true],
80
            'session' => ['handler_id' => null, 'storage_id' => 'session.storage.mock_file', 'name' => 'MOCKSESSID'],
81
            'templating' => ['engine' => ['twig']],
82
            'test' => true,
83
        ]);
84
85
        $containerBuilder->loadFromExtension('security', [
86
            'firewalls' => ['main' => ['anonymous' => true]],
87
            'providers' => ['in_memory' => ['memory' => null]],
88
        ]);
89
90
        $loader->load($this->getProjectDir().'/config/services.yml');
91
    }
92
93
    private function getBaseDir(): string
94
    {
95
        return sys_get_temp_dir().'/sonata-admin-bundle/var/';
96
    }
97
}
98