Completed
Pull Request — master (#8)
by Arnaud
02:50
created

AdminSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 6 1
A __construct() 0 4 1
A kernelRequest() 0 5 1
1
<?php
2
3
namespace LAG\AdminBundle\Event\Subscriber;
4
5
use LAG\AdminBundle\Admin\Factory\AdminFactory;
6
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7
use Symfony\Component\HttpKernel\Event\KernelEvent;
8
use Symfony\Component\HttpKernel\KernelEvents;
9
10
class AdminSubscriber implements EventSubscriberInterface
11
{
12
    /**
13
     * @var AdminFactory
14
     */
15
    protected $adminFactory;
16
17
    /**
18
     * @return array
19
     */
20
    public static function getSubscribedEvents()
21
    {
22
        return [
23
            KernelEvents::REQUEST => 'kernelRequest'
24
        ];
25
    }
26
27
    /**
28
     * AdminSubscriber constructor.
29
     *
30
     * @param AdminFactory $adminFactory
31
     */
32
    public function __construct(AdminFactory $adminFactory)
33
    {
34
        $this->adminFactory = $adminFactory;
35
    }
36
37
    /**
38
     * Init admin factory on kernel request.
39
     */
40
    public function kernelRequest()
41
    {
42
        // init admin factory
43
        $this->adminFactory->init();
44
    }
45
}
46