|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MenuBuilder KnpMenu. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP Version 7 |
|
6
|
|
|
* |
|
7
|
|
|
* @author Quétier Laurent <[email protected]> |
|
8
|
|
|
* @copyright 2014 Dev-Int GLSR |
|
9
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
10
|
|
|
* |
|
11
|
|
|
* @version GIT: <git_id> |
|
12
|
|
|
* |
|
13
|
|
|
* @see https://github.com/Dev-Int/glsr |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace App\Menu; |
|
17
|
|
|
|
|
18
|
|
|
use Knp\Menu\FactoryInterface; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
|
21
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
|
22
|
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* class MenuBuilder. |
|
26
|
|
|
* |
|
27
|
|
|
* @category Menu |
|
28
|
|
|
*/ |
|
29
|
|
|
class MenuBuilder implements ContainerAwareInterface |
|
30
|
|
|
{ |
|
31
|
|
|
use ContainerAwareTrait; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Factory. |
|
35
|
|
|
* |
|
36
|
|
|
* @var FactoryInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $factory; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* TokenStorage. |
|
42
|
|
|
* |
|
43
|
|
|
* @var TokenStorageInterface |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $tokenStorage; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* AuthorizationChecker. |
|
49
|
|
|
* |
|
50
|
|
|
* @var AuthorizationChecker |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $authorizationChecker; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Constructor. |
|
56
|
|
|
* |
|
57
|
|
|
* @param TokenStorageInterface $tokenStorage |
|
58
|
|
|
* @param AuthorizationChecker $authorizationChecker |
|
59
|
|
|
* @param FactoryInterface $factory |
|
60
|
|
|
*/ |
|
61
|
|
|
public function __construct( |
|
62
|
|
|
TokenStorageInterface $tokenStorage, |
|
63
|
|
|
AuthorizationChecker $authorizationChecker, |
|
64
|
|
|
FactoryInterface $factory |
|
65
|
|
|
) { |
|
66
|
|
|
$this->tokenStorage = $tokenStorage; |
|
67
|
|
|
$this->authorizationChecker = $authorizationChecker; |
|
68
|
|
|
$this->factory = $factory; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function buildOrderMenu(array $options) |
|
|
|
|
|
|
72
|
|
|
{ |
|
73
|
|
|
$menu = $this->factory->createItem('root'); |
|
74
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav'); |
|
75
|
|
|
|
|
76
|
|
|
$menu->addChild('order', array('label' => 'menu.order')) |
|
77
|
|
|
->setExtra('translation_domain', 'messages') |
|
78
|
|
|
->setAttribute('dropdown', true) |
|
79
|
|
|
->setAttribute('icon', 'fa fa-shopping-cart'); |
|
80
|
|
|
|
|
81
|
|
|
$menu['order']->addChild('orders', ['label' => 'title_short', 'route' => 'orders']) |
|
82
|
|
|
->setExtra('translation_domain', 'gs_orders') |
|
83
|
|
|
->setAttribute('icon', 'fa fa-shopping-cart'); |
|
84
|
|
|
|
|
85
|
|
|
$menu['order']->addChild('deliveries', ['label' => 'title_short', 'route' => 'deliveries']) |
|
86
|
|
|
->setExtra('translation_domain', 'gs_deliveries') |
|
87
|
|
|
->setAttribute('icon', 'fa fa-truck'); |
|
88
|
|
|
|
|
89
|
|
|
$menu['order']->addChild('invoices', ['label' => 'title_short', 'route' => 'invoices']) |
|
90
|
|
|
->setExtra('translation_domain', 'gs_invoices') |
|
91
|
|
|
->setAttribute('icon', 'fa fa-calculator'); |
|
92
|
|
|
|
|
93
|
|
|
return $menu; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function buildStockMenu(array $options) |
|
|
|
|
|
|
97
|
|
|
{ |
|
98
|
|
|
$menu = $this->factory->createItem('root'); |
|
99
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav'); |
|
100
|
|
|
|
|
101
|
|
|
$menu->addChild('stock', array('label' => 'menu.stock')) |
|
102
|
|
|
->setExtra('translation_domain', 'messages') |
|
103
|
|
|
->setAttribute('dropdown', true) |
|
104
|
|
|
->setAttribute('icon', 'fa fa-dashboard'); |
|
105
|
|
|
|
|
106
|
|
|
$menu['stock']->addChild('inventory', ['label' => 'title_short', 'route' => 'inventory']) |
|
107
|
|
|
->setExtra('translation_domain', 'gs_inventories') |
|
108
|
|
|
->setAttribute('icon', 'fa fa-tasks'); |
|
109
|
|
|
|
|
110
|
|
|
$menu['stock']->addChild('articles', ['label' => 'menu.articles', 'route' => 'article']) |
|
111
|
|
|
->setExtra('translation_domain', 'gs_articles') |
|
112
|
|
|
->setAttribute('icon', 'fa fa-list'); |
|
113
|
|
|
|
|
114
|
|
|
return $menu; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function buildConfigMenu(array $options) |
|
|
|
|
|
|
118
|
|
|
{ |
|
119
|
|
|
$menu = $this->factory->createItem('root'); |
|
120
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav'); |
|
121
|
|
|
|
|
122
|
|
|
$menu->addChild('config', array('label' => 'menu.configuration')) |
|
123
|
|
|
->setExtra('translation_domain', 'messages') |
|
124
|
|
|
->setAttribute('dropdown', true) |
|
125
|
|
|
->setAttribute('icon', 'fa fa-cog'); |
|
126
|
|
|
|
|
127
|
|
|
$menu['config']->addChild('company', ['route' => 'company', 'label' => 'gestock.settings.company.title']) |
|
128
|
|
|
->setExtra('translation_domain', 'messages') |
|
129
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-tower'); |
|
130
|
|
|
|
|
131
|
|
|
$menu['config'] |
|
132
|
|
|
->addChild('applcation', ['route' => 'application', 'label' => 'gestock.settings.settings.title']) |
|
133
|
|
|
->setExtra('translation_domain', 'messages') |
|
134
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-wrench') |
|
135
|
|
|
->setAttribute('divider_append', true); |
|
136
|
|
|
|
|
137
|
|
|
$menu['config']->addChild('suppliers', ['label' => 'title', 'route' => 'supplier']) |
|
138
|
|
|
->setExtra('translation_domain', 'gs_suppliers') |
|
139
|
|
|
->setAttribute('icon', 'fa fa-barcode'); |
|
140
|
|
|
|
|
141
|
|
|
$menu['config']->addChild('article', ['label' => 'title', 'route' => 'article']) |
|
142
|
|
|
->setExtra('translation_domain', 'gs_articles') |
|
143
|
|
|
->setAttribute('icon', 'fa fa-shopping-basket'); |
|
144
|
|
|
|
|
145
|
|
|
$divers = $menu['config']->addChild('divers', ['label' => 'gestock.settings.diverse.title']) |
|
146
|
|
|
->setExtra('translation_domain', 'messages') |
|
147
|
|
|
->setAttribute('dropdown', true) |
|
148
|
|
|
->setAttribute('class', 'dropdown-submenu') |
|
149
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-info-sign'); |
|
150
|
|
|
|
|
151
|
|
|
$divers->addChild('familylog', ['route' => 'familylog', 'label' => 'gestock.settings.diverse.familylog']) |
|
152
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-tag'); |
|
153
|
|
|
|
|
154
|
|
|
$divers |
|
155
|
|
|
->addChild('zonestorage', ['route' => 'zonestorage', 'label' => 'gestock.settings.diverse.zonestorage']) |
|
156
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-map-marker'); |
|
157
|
|
|
|
|
158
|
|
|
$divers |
|
159
|
|
|
->addChild('unit', ['route' => 'unit', 'label' => 'gestock.settings.diverse.unit']) |
|
160
|
|
|
->setAttribute('icon', 'fa fa-cubes'); |
|
161
|
|
|
|
|
162
|
|
|
$divers->addChild('tva', ['route' => 'tva', 'label' => 'gestock.settings.diverse.vat']) |
|
163
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-piggy-bank'); |
|
164
|
|
|
|
|
165
|
|
|
$divers->addChild('material', ['route' => 'material', 'label' => 'menu.material']) |
|
166
|
|
|
->setAttribute('icon', 'fa fa-pie-chart'); |
|
167
|
|
|
|
|
168
|
|
|
return $menu; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/* |
|
172
|
|
|
public function buildUserMenu(array $options) |
|
173
|
|
|
{ |
|
174
|
|
|
$menu = $this->factory->createItem('root'); |
|
175
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav navbar-right'); |
|
176
|
|
|
|
|
177
|
|
|
if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { |
|
178
|
|
|
// Menu Administration |
|
179
|
|
|
|
|
180
|
|
|
$menu->addChild('entities', ['label' => 'menu.staf']) |
|
181
|
|
|
->setExtra('translation_domain', 'messages') |
|
182
|
|
|
->setAttribute('dropdown', true) |
|
183
|
|
|
->setAttribute('class', 'multi-level') |
|
184
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-cog'); |
|
185
|
|
|
|
|
186
|
|
|
$menu['entities']->addChild('users', ['route' => 'user', 'label' => 'menu.users']) |
|
187
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-user'); |
|
188
|
|
|
|
|
189
|
|
|
$menu['entities']->addChild('groups', ['route' => 'group', 'label' => 'menu.groups']) |
|
190
|
|
|
->setAttribute('icon', 'fa fa-users'); |
|
191
|
|
|
} |
|
192
|
|
|
// Menu Profile |
|
193
|
|
|
|
|
194
|
|
|
if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { |
|
195
|
|
|
$menu->addChild('profile', array( |
|
196
|
|
|
'label' => $this->tokenStorage->getToken()->getUser()->getUsername(), )) |
|
197
|
|
|
->setAttribute('dropdown', true) |
|
198
|
|
|
->setAttribute('icon', 'fa fa-user'); |
|
199
|
|
|
|
|
200
|
|
|
$menu['profile']->addChild('layout.logout', ['route' => 'fos_user_security_logout']) |
|
201
|
|
|
->setExtra('translation_domain', 'FOSUserBundle') |
|
202
|
|
|
->setAttribute('icon', 'fa fa-unlink'); |
|
203
|
|
|
} else { |
|
204
|
|
|
$menu->addChild('profile', ['label' => 'menu.administration']) |
|
205
|
|
|
->setExtra('translation_domain', 'messages') |
|
206
|
|
|
->setAttribute('dropdown', true) |
|
207
|
|
|
->setAttribute('icon', 'fa fa-user'); |
|
208
|
|
|
} |
|
209
|
|
|
$menu['profile']->addChild('menu.other_login', ['route' => 'fos_user_security_login']) |
|
210
|
|
|
->setAttribute('icon', 'fa fa-link'); |
|
211
|
|
|
|
|
212
|
|
|
return $menu; |
|
213
|
|
|
} |
|
214
|
|
|
*/ |
|
215
|
|
|
} |
|
216
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.