Completed
Pull Request — dev (#43)
by Arnaud
03:21
created

TemplateSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 3
c 3
b 2
f 0
lcom 1
cbo 2
dl 0
loc 43
ccs 0
cts 15
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 6 1
A kernelView() 0 4 1
A __construct() 0 5 1
1
<?php
2
3
namespace LAG\AdminBundle\Event\Subscriber;
4
5
use LAG\AdminBundle\Application\Configuration\ApplicationConfiguration;
6
use LAG\AdminBundle\Configuration\Factory\ConfigurationFactory;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
use Symfony\Component\HttpKernel\KernelEvents;
9
use Twig_Environment;
10
11
class TemplateSubscriber implements EventSubscriberInterface
12
{
13
    /**
14
     * @var Twig_Environment
15
     */
16
    protected $twig;
17
18
    /**
19
     * @var ApplicationConfiguration
20
     */
21
    protected $configuration;
22
23
    /**
24
     * TemplateSubscriber constructor.
25
     *
26
     * @param Twig_Environment $twig
27
     * @param ConfigurationFactory $configurationFactory
28
     */
29
    public function __construct(Twig_Environment $twig, ConfigurationFactory $configurationFactory)
30
    {
31
        $this->twig = $twig;
32
        $this->configuration = $configurationFactory->getApplicationConfiguration();
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public static function getSubscribedEvents()
39
    {
40
        return [
41
            KernelEvents::REQUEST => 'kernelView',
42
        ];
43
    }
44
45
    /**
46
     *
47
     * @return null
48
     */
49
    public function kernelView()
50
    {
51
        $this->twig->addGlobal('config', $this->configuration);
52
    }
53
}
54