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
|
|
|
* @package Oc\Account\Subscriber |
13
|
|
|
*/ |
14
|
|
|
class MenuSubscriber implements EventSubscriberInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Returns an array of event names this subscriber wants to listen to. |
18
|
|
|
* |
19
|
|
|
* @return array The event names to listen to |
20
|
|
|
*/ |
21
|
|
|
public static function getSubscribedEvents() |
22
|
|
|
{ |
23
|
|
|
return [ |
24
|
|
|
MenuEnum::MENU_MAIN => ['onConfigureMenuMain', 1], |
25
|
|
|
MenuEnum::MENU_MAIN_ACCOUNT => ['onConfigureMenuMainAccount', 0] |
26
|
|
|
]; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param MenuEvent $event |
31
|
|
|
*/ |
32
|
|
|
public function onConfigureMenuMain(MenuEvent $event) |
33
|
|
|
{ |
34
|
|
|
$accountItem = $event->getCurrentItem()->addChild('account', ['label' => 'Benutzerkonto']); |
35
|
|
|
|
36
|
|
|
$accountEvent = $event->createSubEvent($accountItem); |
37
|
|
|
|
38
|
|
|
$event->getEventDispatcher()->dispatch( |
39
|
|
|
MenuEnum::MENU_MAIN_ACCOUNT, |
40
|
|
|
$accountEvent |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param MenuEvent $event |
46
|
|
|
*/ |
47
|
|
|
public function onConfigureMenuMainAccount(MenuEvent $event) |
48
|
|
|
{ |
49
|
|
|
$currentItem = $event->getCurrentItem(); |
50
|
|
|
|
51
|
|
|
$currentItem->addChild('profile', ['label' => 'Mein Profil']); |
52
|
|
|
|
53
|
|
|
$currentItem->addChild('statistics', ['label' => 'Statistik']); |
54
|
|
|
|
55
|
|
|
$currentItem->addChild('contacts', ['label' => 'Kontakte']); |
56
|
|
|
|
57
|
|
|
$currentItem->addChild('settings', ['label' => 'Einstellungen']); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|