1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Packy. |
5
|
|
|
* |
6
|
|
|
* (c) Peter Nijssen |
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 AppBundle\Menu; |
13
|
|
|
|
14
|
|
|
use Knp\Menu\FactoryInterface; |
15
|
|
|
use Knp\Menu\ItemInterface; |
16
|
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; |
17
|
|
|
|
18
|
|
|
class Builder |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var FactoryInterface |
22
|
|
|
*/ |
23
|
|
|
private $factory; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var AuthorizationChecker |
27
|
|
|
*/ |
28
|
|
|
private $security; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param FactoryInterface $factory |
32
|
|
|
* @param AuthorizationChecker $security |
33
|
|
|
* |
34
|
|
|
* Add any other dependency you need |
35
|
|
|
*/ |
36
|
|
|
public function __construct(FactoryInterface $factory, AuthorizationChecker $security) |
37
|
|
|
{ |
38
|
|
|
$this->factory = $factory; |
39
|
|
|
$this->security = $security; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Create the side menu |
44
|
|
|
* |
45
|
|
|
* @return ItemInterface |
46
|
|
|
*/ |
47
|
|
|
public function createSideMenu() |
48
|
|
|
{ |
49
|
|
|
$menu = $this->factory->createItem('root'); |
50
|
|
|
$menu->setChildrenAttribute('class', 'sidebar-menu'); |
51
|
|
|
|
52
|
|
|
$menu->addChild( |
53
|
|
|
'Projects', |
54
|
|
|
array( |
55
|
|
|
'route' => 'packy_project_overview', |
56
|
|
|
'extras' => array( |
57
|
|
|
'icon' => 'fa-tasks fa-fw', |
58
|
|
|
), |
59
|
|
|
) |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
if ($this->security->isGranted('ROLE_ADMIN')) { |
63
|
|
|
$menu->addChild( |
64
|
|
|
'Users', |
65
|
|
|
[ |
66
|
|
|
'route' => 'packy_user_overview', |
67
|
|
|
'extras' => [ |
68
|
|
|
'icon' => 'fa-users fa-fw', |
69
|
|
|
], |
70
|
|
|
] |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/*$settingsMenu = $menu->addChild( |
75
|
|
|
'Settings', |
76
|
|
|
array( |
77
|
|
|
'childrenAttributes' => array('class' => 'treeview-menu'), |
78
|
|
|
'route' => 'packy_settings_overview', |
79
|
|
|
'attributes' => array('class' => 'treeview'), |
80
|
|
|
'extras' => array( |
81
|
|
|
'icon' => 'fa-cogs fa-fw', |
82
|
|
|
), |
83
|
|
|
) |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
$this->settingsMenu($settingsMenu);*/ |
87
|
|
|
|
88
|
|
|
return $menu; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Settings sub menu |
93
|
|
|
* |
94
|
|
|
* @param ItemInterface $menu |
95
|
|
|
* |
96
|
|
|
* @return ItemInterface |
97
|
|
|
*/ |
98
|
|
|
protected function settingsMenu(ItemInterface $menu) |
99
|
|
|
{ |
100
|
|
|
return $menu; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|