Completed
Push — development ( 0937b7...1a7c5e )
by Thomas
21s
created

MenuEvent::getFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Oc\Menu\Event;
4
5
use Knp\Menu\FactoryInterface;
6
use Knp\Menu\ItemInterface;
7
use Symfony\Component\EventDispatcher\Event;
8
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9
10
class MenuEvent extends Event
11
{
12
    /**
13
     * @var FactoryInterface
14
     */
15
    private $factory;
16
17
    /**
18
     * @var ItemInterface
19
     */
20
    private $menu;
21
22
    /**
23
     * @var ItemInterface
24
     */
25
    private $currentItem;
26
    /**
27
     * @var EventDispatcherInterface
28
     */
29
    private $eventDispatcher;
30
31
    /**
32
     * ConfigureMenuEvent constructor.
33
     *
34
     * @param EventDispatcherInterface $eventDispatcher
35
     * @param FactoryInterface $factory
36
     * @param ItemInterface $menu
37
     * @param ItemInterface $currentItem
38
     */
39
    public function __construct(
40
        EventDispatcherInterface $eventDispatcher,
41
        FactoryInterface $factory,
42
        ItemInterface $menu,
43
        ItemInterface $currentItem
44
    ) {
45
        $this->eventDispatcher = $eventDispatcher;
46
        $this->factory = $factory;
47
        $this->menu = $menu;
48
        $this->currentItem = $currentItem;
49
    }
50
51
    /**
52
     * @return EventDispatcherInterface
53
     */
54
    public function getEventDispatcher()
55
    {
56
        return $this->eventDispatcher;
57
    }
58
59
    /**
60
     * @return FactoryInterface
61
     */
62
    public function getFactory()
63
    {
64
        return $this->factory;
65
    }
66
67
    /**
68
     * @return ItemInterface
69
     */
70
    public function getMenu()
71
    {
72
        return $this->menu;
73
    }
74
75
    /**
76
     * @return ItemInterface
77
     */
78
    public function getCurrentItem()
79
    {
80
        return $this->currentItem;
81
    }
82
83
    /**
84
     * Creates an event object of it self but with given currentItem.
85
     *
86
     * @param ItemInterface $currentItem
87
     *
88
     * @return self
89
     */
90
    public function createSubEvent(ItemInterface $currentItem)
91
    {
92
        return new self(
93
            $this->eventDispatcher,
94
            $this->factory,
95
            $this->menu,
96
            $currentItem
97
        );
98
    }
99
}
100