Completed
Push — next ( 8ef386...43bb99 )
by Thomas
11:01 queued 05:16
created

MenuSubscriber::onConfigureMenuMainAccount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Oc\Account\Subscriber;
4
5
use Oc\Menu\Event\MenuEvent;
6
use Oc\Menu\MenuEnum;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
/**
10
 * Class MenuSubscriber
11
 */
12
class MenuSubscriber implements EventSubscriberInterface
13
{
14
    /**
15
     * Returns an array of event names this subscriber wants to listen to.
16
     *
17
     * @return array The event names to listen to
18
     */
19
    public static function getSubscribedEvents()
20
    {
21
        return [
22
            MenuEnum::MENU_MAIN => ['onConfigureMenuMain', 1],
23
            MenuEnum::MENU_MAIN_ACCOUNT => ['onConfigureMenuMainAccount', 0],
24
        ];
25
    }
26
27
    /**
28
     * @param MenuEvent $event
29
     */
30
    public function onConfigureMenuMain(MenuEvent $event)
31
    {
32
        $accountItem = $event->getCurrentItem()->addChild('account', ['label' => 'Benutzerkonto']);
33
34
        $accountEvent = $event->createSubEvent($accountItem);
35
36
        $event->getEventDispatcher()->dispatch(
37
            MenuEnum::MENU_MAIN_ACCOUNT,
38
            $accountEvent
39
        );
40
    }
41
42
    /**
43
     * @param MenuEvent $event
44
     */
45
    public function onConfigureMenuMainAccount(MenuEvent $event)
46
    {
47
        $currentItem = $event->getCurrentItem();
48
49
        $currentItem->addChild('profile', ['label' => 'Mein Profil']);
50
51
        $currentItem->addChild('statistics', ['label' => 'Statistik']);
52
53
        $currentItem->addChild('contacts', ['label' => 'Kontakte']);
54
55
        $currentItem->addChild('settings', ['label' => 'Einstellungen']);
56
    }
57
}
58