AppKernel::configureContainer()   A
last analyzed

Complexity

Conditions 5
Paths 12

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2568
c 0
b 0
f 0
cc 5
nc 12
nop 2
1
<?php
2
3
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
4
use Symfony\Component\Config\Loader\LoaderInterface;
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\HttpKernel\Kernel;
7
use Symfony\Component\Routing\RouteCollectionBuilder;
8
9
class AppKernel extends Kernel
10
{
11
    use MicroKernelTrait;
12
13
    private $config = [];
14
    private $services = [];
15
    private $cacheDir;
16
17
    public function registerBundles()
18
    {
19
        return [
20
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
21
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
22
            new League\Tactician\Bundle\TacticianBundle(),
23
        ];
24
    }
25
26
    public function defineCacheDir($dir)
27
    {
28
        $this->cacheDir = $dir;
29
    }
30
31
    public function loadConfig($namespace, array $tacticianConfig)
32
    {
33
        $this->config[$namespace] = $tacticianConfig;
34
    }
35
36
    public function addServiceToRegister($serviceId, $className, array $tags)
37
    {
38
        $this->services[$serviceId] = [
39
            'className' => $className,
40
            'tags' => $tags,
41
        ];
42
    }
43
44
    public function getCacheDir()
45
    {
46
        return $this->cacheDir;
47
    }
48
49
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $loader is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
    {
51
        $frameworkConfig = ['secret' => 'S0ME_SECRET'];
52
        if (array_key_exists('framework', $this->config)) {
53
            $this->config['framework'] = array_merge($frameworkConfig, $this->config['framework']);
54
        } else {
55
            $this->config['framework'] = $frameworkConfig;
56
        }
57
58
        foreach ($this->config as $namespace => $config) {
59
            $c->loadFromExtension($namespace, $config);
60
        }
61
62
        foreach ($this->services as $serviceId => $definition) {
63
            $service = $c->register($serviceId, $definition['className']);
64
            foreach ($definition['tags'] as $tag) {
65
                $tagName = $tag['name'];
66
                unset($tag['name']);
67
                $service->addTag($tagName, $tag);
68
            }
69
        }
70
    }
71
72
    protected function configureRoutes(RouteCollectionBuilder $routes)
0 ignored issues
show
Unused Code introduced by
The parameter $routes is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
73
    {
74
    }
75
}
76