|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
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
|
|
|
namespace Sylius\Bundle\AdminBundle\Menu; |
|
13
|
|
|
|
|
14
|
|
|
use Knp\Menu\ItemInterface; |
|
15
|
|
|
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
final class MainMenuBuilder extends AbstractAdminMenuBuilder |
|
21
|
|
|
{ |
|
22
|
|
|
const EVENT_NAME = 'sylius.menu.admin.main'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @return ItemInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
public function createMenu() |
|
28
|
|
|
{ |
|
29
|
|
|
$menu = $this->factory->createItem('root'); |
|
30
|
|
|
|
|
31
|
|
|
$this->addConfigurationMenu($menu); |
|
32
|
|
|
|
|
33
|
|
|
$this->eventDispatcher->dispatch(self::EVENT_NAME, new MenuBuilderEvent($this->factory, $menu)); |
|
34
|
|
|
|
|
35
|
|
|
return $menu; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param ItemInterface $menu |
|
40
|
|
|
*/ |
|
41
|
|
|
private function addConfigurationMenu(ItemInterface $menu) |
|
42
|
|
|
{ |
|
43
|
|
|
$child = $menu |
|
44
|
|
|
->addChild('configuration') |
|
45
|
|
|
->setLabel('sylius.menu.admin.main.configuration.header') |
|
46
|
|
|
; |
|
47
|
|
|
|
|
48
|
|
|
$child |
|
49
|
|
|
->addChild('tax_categories', ['route' => 'sylius_admin_tax_category_index']) |
|
50
|
|
|
->setLabel('sylius.menu.admin.main.configuration.tax_categories') |
|
51
|
|
|
->setLabelAttribute('icon', 'tags') |
|
52
|
|
|
; |
|
53
|
|
|
|
|
54
|
|
|
$child |
|
55
|
|
|
->addChild('countries', ['route' => 'sylius_admin_country_index']) |
|
56
|
|
|
->setLabel('sylius.menu.admin.main.configuration.countries') |
|
57
|
|
|
->setLabelAttribute('icon', 'flag') |
|
58
|
|
|
; |
|
59
|
|
|
|
|
60
|
|
|
$child |
|
61
|
|
|
->addChild('locale', ['route' => 'sylius_admin_locale_index']) |
|
62
|
|
|
->setLabel('sylius.menu.admin.main.configuration.locales') |
|
63
|
|
|
->setLabelAttribute('icon', 'translate') |
|
64
|
|
|
; |
|
65
|
|
|
|
|
66
|
|
|
if (!$child->hasChildren()) { |
|
67
|
|
|
$menu->removeChild('configuration'); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|