|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of AppName. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Monofony |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace App\Menu; |
|
15
|
|
|
|
|
16
|
|
|
use Knp\Menu\FactoryInterface; |
|
17
|
|
|
use Knp\Menu\ItemInterface; |
|
18
|
|
|
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent; |
|
19
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
20
|
|
|
|
|
21
|
|
|
final class AccountMenuBuilder |
|
22
|
|
|
{ |
|
23
|
|
|
public const EVENT_NAME = 'sylius.menu.app.account'; |
|
24
|
|
|
|
|
25
|
|
|
/** @var FactoryInterface */ |
|
26
|
|
|
private $factory; |
|
27
|
|
|
|
|
28
|
|
|
/** @var EventDispatcherInterface */ |
|
29
|
|
|
private $eventDispatcher; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct(FactoryInterface $factory, EventDispatcherInterface $eventDispatcher) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->factory = $factory; |
|
34
|
|
|
$this->eventDispatcher = $eventDispatcher; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function createMenu(array $options): ItemInterface |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
$menu = $this->factory->createItem('root'); |
|
40
|
|
|
$menu->setLabel('sylius.ui.my_account'); |
|
41
|
|
|
|
|
42
|
|
|
$menu |
|
43
|
|
|
->addChild('dashboard', ['route' => 'sylius_frontend_account_dashboard']) |
|
44
|
|
|
->setLabel('sylius.ui.dashboard') |
|
45
|
|
|
->setLabelAttribute('icon', 'home') |
|
46
|
|
|
; |
|
47
|
|
|
$menu |
|
48
|
|
|
->addChild('personal_information', ['route' => 'sylius_frontend_account_profile_update']) |
|
49
|
|
|
->setLabel('sylius.ui.personal_information') |
|
50
|
|
|
->setLabelAttribute('icon', 'user') |
|
51
|
|
|
; |
|
52
|
|
|
$menu |
|
53
|
|
|
->addChild('change_password', ['route' => 'sylius_frontend_account_change_password']) |
|
54
|
|
|
->setLabel('sylius.ui.change_password') |
|
55
|
|
|
->setLabelAttribute('icon', 'lock') |
|
56
|
|
|
; |
|
57
|
|
|
|
|
58
|
|
|
$this->eventDispatcher->dispatch(new MenuBuilderEvent($this->factory, $menu), self::EVENT_NAME); |
|
59
|
|
|
|
|
60
|
|
|
return $menu; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.