Completed
Push — dev ( 4306de...25864c )
by Arnaud
02:52
created

TemplateSubscriber::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
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