Completed
Pull Request — master (#6204)
by
unknown
04:06 queued 45s
created

AppKernel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle;
20
use Sonata\Form\Bridge\Symfony\Bundle\SonataFormBundle;
21
use Sonata\Form\Bridge\Symfony\SonataFormBundle;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Cannot use Sonata\Form\Bridge\Symfony\SonataFormBundle as SonataFormBundle because the name is already in use
Loading history...
22
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
23
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
24
use Symfony\Bundle\SecurityBundle\SecurityBundle;
25
use Symfony\Bundle\TwigBundle\TwigBundle;
26
use Symfony\Component\Config\Loader\LoaderInterface;
27
use Symfony\Component\DependencyInjection\ContainerBuilder;
28
use Symfony\Component\HttpKernel\Kernel;
29
use Symfony\Component\Routing\RouteCollectionBuilder;
30
31
final class AppKernel extends Kernel
32
{
33
    use MicroKernelTrait;
34
35
    public function __construct()
36
    {
37
        parent::__construct('test', false);
38
    }
39
40
    public function registerBundles()
41
    {
42
        $bundles = [
43
            new FrameworkBundle(),
44
            new TwigBundle(),
45
            new SecurityBundle(),
46
            new KnpMenuBundle(),
47
            new SonataBlockBundle(),
48
            new SonataDoctrineBundle(),
49
            new SonataAdminBundle(),
50
            new SonataTwigBundle(),
51
            new SonataFormBundle(),
52
        ];
53
54
        if (class_exists(SonataCoreBundle::class)) {
55
            $bundles[] = new SonataCoreBundle();
56
        }
57
58
        return $bundles;
59
    }
60
61
    public function getCacheDir(): string
62
    {
63
        return sprintf('%scache', $this->getBaseDir());
64
    }
65
66
    public function getLogDir(): string
67
    {
68
        return sprintf('%slog', $this->getBaseDir());
69
    }
70
71
    public function getProjectDir()
72
    {
73
        return __DIR__;
74
    }
75
76
    protected function configureRoutes(RouteCollectionBuilder $routes)
77
    {
78
        $routes->import(sprintf('%s/config/routes.yml', $this->getProjectDir()));
79
    }
80
81
    protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader)
82
    {
83
        $containerBuilder->loadFromExtension('framework', [
84
            'secret' => 'MySecret',
85
            'fragments' => ['enabled' => true],
86
            'form' => ['enabled' => true],
87
            'session' => ['handler_id' => 'session.handler.native_file', 'storage_id' => 'session.storage.mock_file', 'name' => 'MOCKSESSID'],
88
            'assets' => null,
89
            'test' => true,
90
        ]);
91
92
        $containerBuilder->loadFromExtension('security', [
93
            'firewalls' => ['main' => ['anonymous' => true]],
94
            'providers' => ['in_memory' => ['memory' => null]],
95
        ]);
96
97
        $containerBuilder->loadFromExtension('twig', [
98
            'strict_variables' => '%kernel.debug%',
99
            'exception_controller' => null,
100
        ]);
101
102
        $loader->load(sprintf('%s/config/services.yml', $this->getProjectDir()));
103
    }
104
105
    private function getBaseDir(): string
106
    {
107
        return sprintf('%s/sonata-admin-bundle/var/', sys_get_temp_dir());
108
    }
109
}
110