1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MenuBuilder KnpMenu. |
4
|
|
|
* |
5
|
|
|
* PHP Version 5 |
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 since 1.0.0 |
12
|
|
|
* |
13
|
|
|
* @link https://github.com/Dev-Int/glsr |
14
|
|
|
*/ |
15
|
|
|
namespace AppBundle\Menu; |
16
|
|
|
|
17
|
|
|
use Knp\Menu\FactoryInterface; |
18
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* class MenuBuilder. |
23
|
|
|
* |
24
|
|
|
* @category Menu |
25
|
|
|
*/ |
26
|
|
|
class MenuBuilder implements ContainerAwareInterface |
27
|
|
|
{ |
28
|
|
|
use ContainerAwareTrait; |
29
|
|
|
public function buildOrderMenu(FactoryInterface $factory) |
30
|
|
|
{ |
31
|
|
|
$menu = $factory->createItem('root'); |
32
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav'); |
33
|
|
|
|
34
|
|
|
$menu->addChild('order', array('label' => 'menu.order')) |
35
|
|
|
->setExtra('translation_domain', 'messages') |
36
|
|
|
->setAttribute('dropdown', true) |
37
|
|
|
->setAttribute('icon', 'fa fa-shopping-cart'); |
38
|
|
|
|
39
|
|
|
$menu['order']->addChild('orders', ['label' => 'title_short', 'route' => 'orders', ]) |
40
|
|
|
->setExtra('translation_domain', 'gs_orders') |
41
|
|
|
->setAttribute('icon', 'fa fa-shopping-cart'); |
42
|
|
|
|
43
|
|
|
$menu['order']->addChild('deliveries', ['label' => 'title_short', 'route' => 'deliveries', ]) |
44
|
|
|
->setExtra('translation_domain', 'gs_deliveries') |
45
|
|
|
->setAttribute('icon', 'fa fa-truck'); |
46
|
|
|
|
47
|
|
|
$menu['order']->addChild('invoices', ['label' => 'title_short', 'route' => 'invoices', ]) |
48
|
|
|
->setExtra('translation_domain', 'gs_invoices') |
49
|
|
|
->setAttribute('icon', 'fa fa-calculator'); |
50
|
|
|
|
51
|
|
|
return $menu; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function buildStockMenu(FactoryInterface $factory) |
55
|
|
|
{ |
56
|
|
|
$menu = $factory->createItem('root'); |
57
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav'); |
58
|
|
|
|
59
|
|
|
$menu->addChild('stock', array('label' => 'menu.stock')) |
60
|
|
|
->setExtra('translation_domain', 'messages') |
61
|
|
|
->setAttribute('dropdown', true) |
62
|
|
|
->setAttribute('icon', 'fa fa-dashboard'); |
63
|
|
|
|
64
|
|
|
$menu['stock']->addChild('inventory', ['label' => 'title_short', 'route' => 'inventory', ]) |
65
|
|
|
->setExtra('translation_domain', 'gs_inventories') |
66
|
|
|
->setAttribute('icon', 'fa fa-tasks'); |
67
|
|
|
|
68
|
|
|
$menu['stock']->addChild('articles', ['label' => 'menu.articles', 'route' => 'article', ]) |
69
|
|
|
->setExtra('translation_domain', 'gs_articles') |
70
|
|
|
->setAttribute('icon', 'fa fa-list'); |
71
|
|
|
|
72
|
|
|
return $menu; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function buildConfigMenu(FactoryInterface $factory) |
76
|
|
|
{ |
77
|
|
|
$menu = $factory->createItem('root'); |
78
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav'); |
79
|
|
|
|
80
|
|
|
$menu->addChild('config', array('label' => 'menu.configuration')) |
81
|
|
|
->setExtra('translation_domain', 'messages') |
82
|
|
|
->setAttribute('dropdown', true) |
83
|
|
|
->setAttribute('icon', 'fa fa-cog'); |
84
|
|
|
|
85
|
|
|
$menu['config']->addChild('suppliers', ['label' => 'title', 'route' => 'supplier', ]) |
86
|
|
|
->setExtra('translation_domain', 'gs_suppliers') |
87
|
|
|
->setAttribute('icon', 'fa fa-barcode'); |
88
|
|
|
|
89
|
|
|
$menu['config']->addChild('article', ['label' => 'title', 'route' => 'article', ]) |
90
|
|
|
->setExtra('translation_domain', 'gs_articles') |
91
|
|
|
->setAttribute('icon', 'fa fa-shopping-basket'); |
92
|
|
|
|
93
|
|
|
$menu['config']->addChild('company', ['route' => 'company', 'label' => 'gestock.settings.company.title', ]) |
94
|
|
|
->setExtra('translation_domain', 'messages') |
95
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-tower'); |
96
|
|
|
|
97
|
|
|
$menu['config'] |
98
|
|
|
->addChild('applcation', ['route' => 'application', 'label' => 'gestock.settings.settings.title', ]) |
99
|
|
|
->setExtra('translation_domain', 'messages') |
100
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-wrench'); |
101
|
|
|
|
102
|
|
|
$divers = $menu['config']->addChild('divers', ['label' => 'gestock.settings.diverse.title', ]) |
103
|
|
|
->setExtra('translation_domain', 'messages') |
104
|
|
|
->setAttribute('dropdown', true) |
105
|
|
|
->setAttribute('class', 'dropdown-submenu') |
106
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-info-sign'); |
107
|
|
|
|
108
|
|
|
$divers->addChild('familylog', ['route' => 'familylog', 'label' => 'gestock.settings.diverse.familylog', ]) |
109
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-tag'); |
110
|
|
|
|
111
|
|
|
$divers |
112
|
|
|
->addChild('zonestorage', ['route' => 'zonestorage', 'label' => 'gestock.settings.diverse.zonestorage', ]) |
113
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-map-marker'); |
114
|
|
|
|
115
|
|
|
$divers |
116
|
|
|
->addChild('unitstorage', ['route' => 'unitstorage', 'label' => 'gestock.settings.diverse.unitstorage', ]) |
117
|
|
|
->setAttribute('icon', 'fa fa-cubes'); |
118
|
|
|
|
119
|
|
|
$divers->addChild('tva', ['route' => 'tva', 'label' => 'gestock.settings.diverse.vat', ]) |
120
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-piggy-bank'); |
121
|
|
|
|
122
|
|
|
return $menu; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function buildUserMenu(FactoryInterface $factory) |
126
|
|
|
{ |
127
|
|
|
$menu = $factory->createItem('root'); |
128
|
|
|
$menu->setChildrenAttribute('class', 'nav navbar-nav navbar-right'); |
129
|
|
|
|
130
|
|
|
$context = $this->container->get('security.authorization_checker'); |
131
|
|
|
if ($context->isGranted('IS_AUTHENTICATED_REMEMBERED')) { |
132
|
|
|
/* |
133
|
|
|
* Menu Administration |
134
|
|
|
*/ |
135
|
|
|
$menu->addChild('entities', ['label' => 'menu.staf']) |
136
|
|
|
->setExtra('translation_domain', 'messages') |
137
|
|
|
->setAttribute('dropdown', true) |
138
|
|
|
->setAttribute('class', 'multi-level') |
139
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-cog'); |
140
|
|
|
|
141
|
|
|
$menu['entities']->addChild('users', ['route' => 'user', 'label' => 'menu.users', ]) |
142
|
|
|
->setAttribute('icon', 'glyphicon glyphicon-user'); |
143
|
|
|
|
144
|
|
|
$menu['entities']->addChild('groups', ['route' => 'group', 'label' => 'menu.groups', ]) |
145
|
|
|
->setAttribute('icon', 'fa fa-users'); |
146
|
|
|
} |
147
|
|
|
/* |
148
|
|
|
* Menu Profile |
149
|
|
|
*/ |
150
|
|
|
$context2 = $this->container->get('security.token_storage'); |
151
|
|
|
if ($context->isGranted('IS_AUTHENTICATED_REMEMBERED')) { |
152
|
|
|
$menu->addChild('profile', array( |
153
|
|
|
'label' => $context2->getToken()->getUser()->getUsername())) |
154
|
|
|
->setAttribute('dropdown', true) |
155
|
|
|
->setAttribute('icon', 'fa fa-user'); |
156
|
|
|
|
157
|
|
|
$menu['profile']->addChild('layout.logout', ['route' => 'fos_user_security_logout', ]) |
158
|
|
|
->setExtra('translation_domain', 'FOSUserBundle') |
159
|
|
|
->setAttribute('icon', 'fa fa-unlink'); |
160
|
|
|
} else { |
161
|
|
|
$menu->addChild('profile', ['label' => 'menu.administration', ]) |
162
|
|
|
->setExtra('translation_domain', 'messages') |
163
|
|
|
->setAttribute('dropdown', true) |
164
|
|
|
->setAttribute('icon', 'fa fa-user'); |
165
|
|
|
} |
166
|
|
|
$menu['profile']->addChild('menu.other_login', ['route' => 'fos_user_security_login', ]) |
167
|
|
|
->setAttribute('icon', 'fa fa-link'); |
168
|
|
|
|
169
|
|
|
return $menu; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|