1 | <?php |
||
22 | final class MainMenuBuilder |
||
23 | { |
||
24 | const EVENT = 'sylius.menu.admin.main'; |
||
25 | |||
26 | /** |
||
27 | * @var FactoryInterface |
||
28 | */ |
||
29 | private $factory; |
||
30 | |||
31 | /** |
||
32 | * @var EventDispatcherInterface |
||
33 | */ |
||
34 | private $eventDispatcher; |
||
35 | |||
36 | /** |
||
37 | * @param FactoryInterface $factory |
||
38 | * @param EventDispatcherInterface $eventDispatcher |
||
39 | */ |
||
40 | public function __construct(FactoryInterface $factory, EventDispatcherInterface $eventDispatcher) |
||
41 | { |
||
42 | $this->factory = $factory; |
||
43 | $this->eventDispatcher = $eventDispatcher; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param array $options |
||
48 | * |
||
49 | * @return ItemInterface |
||
50 | */ |
||
51 | public function createMenu(array $options) |
||
|
|||
52 | { |
||
53 | $menu = $this->factory->createItem('root'); |
||
54 | |||
55 | $this->addCatalogSubMenu($menu); |
||
56 | $this->addSalesSubMenu($menu); |
||
57 | $this->addCustomersSubMenu($menu); |
||
58 | $this->addMarketingSubMenu($menu); |
||
59 | $this->addConfigurationSubMenu($menu); |
||
60 | |||
61 | $this->eventDispatcher->dispatch(self::EVENT, new MenuBuilderEvent($this->factory, $menu)); |
||
62 | |||
63 | return $menu; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param ItemInterface $menu |
||
68 | */ |
||
69 | private function addCatalogSubMenu(ItemInterface $menu) |
||
70 | { |
||
71 | $catalog = $menu |
||
72 | ->addChild('catalog') |
||
73 | ->setLabel('sylius.menu.admin.main.catalog.header') |
||
74 | ; |
||
75 | |||
76 | $catalog |
||
77 | ->addChild('taxons', ['route' => 'sylius_admin_taxon_create']) |
||
78 | ->setLabel('sylius.menu.admin.main.catalog.taxons') |
||
79 | ->setLabelAttribute('icon', 'folder') |
||
80 | ; |
||
81 | |||
82 | $catalog |
||
83 | ->addChild('products', ['route' => 'sylius_admin_product_index']) |
||
84 | ->setLabel('sylius.menu.admin.main.catalog.products') |
||
85 | ->setLabelAttribute('icon', 'cube') |
||
86 | ; |
||
87 | |||
88 | $catalog |
||
89 | ->addChild('attributes', ['route' => 'sylius_admin_product_attribute_index']) |
||
90 | ->setLabel('sylius.menu.admin.main.catalog.attributes') |
||
91 | ->setLabelAttribute('icon', 'cubes') |
||
92 | ; |
||
93 | |||
94 | $catalog |
||
95 | ->addChild('options', ['route' => 'sylius_admin_product_option_index']) |
||
96 | ->setLabel('sylius.menu.admin.main.catalog.options') |
||
97 | ->setLabelAttribute('icon', 'options') |
||
98 | ; |
||
99 | |||
100 | $catalog |
||
101 | ->addChild('association_types', ['route' => 'sylius_admin_product_association_type_index']) |
||
102 | ->setLabel('sylius.menu.admin.main.catalog.association_types') |
||
103 | ->setLabelAttribute('icon', 'tasks') |
||
104 | ; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @param ItemInterface $menu |
||
109 | */ |
||
110 | private function addCustomersSubMenu(ItemInterface $menu) |
||
111 | { |
||
112 | $customers = $menu |
||
113 | ->addChild('customers') |
||
114 | ->setLabel('sylius.menu.admin.main.customers.header') |
||
115 | ; |
||
116 | |||
117 | $customers |
||
118 | ->addChild('customers', ['route' => 'sylius_admin_customer_index']) |
||
119 | ->setLabel('sylius.menu.admin.main.customers.customers') |
||
120 | ->setLabelAttribute('icon', 'users') |
||
121 | ; |
||
122 | |||
123 | $customers |
||
124 | ->addChild('groups', ['route' => 'sylius_admin_customer_group_index']) |
||
125 | ->setLabel('sylius.menu.admin.main.customers.groups') |
||
126 | ->setLabelAttribute('icon', 'archive') |
||
127 | ; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * @param ItemInterface $menu |
||
132 | */ |
||
133 | private function addMarketingSubMenu(ItemInterface $menu) |
||
134 | { |
||
135 | $marketing = $menu |
||
136 | ->addChild('marketing') |
||
137 | ->setLabel('sylius.menu.admin.main.marketing.header') |
||
138 | ; |
||
139 | |||
140 | $marketing |
||
141 | ->addChild('promotions', ['route' => 'sylius_admin_promotion_index']) |
||
142 | ->setLabel('sylius.menu.admin.main.marketing.promotions') |
||
143 | ->setLabelAttribute('icon', 'in cart') |
||
144 | ; |
||
145 | |||
146 | $marketing |
||
147 | ->addChild('product_reviews', ['route' => 'sylius_admin_product_review_index']) |
||
148 | ->setLabel('sylius.menu.admin.main.marketing.product_reviews') |
||
149 | ->setLabelAttribute('icon', 'newspaper') |
||
150 | ; |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @param ItemInterface $menu |
||
155 | */ |
||
156 | private function addSalesSubMenu(ItemInterface $menu) |
||
169 | |||
170 | /** |
||
171 | * @param ItemInterface $menu |
||
172 | */ |
||
173 | private function addConfigurationSubMenu(ItemInterface $menu) |
||
174 | { |
||
252 | } |
||
253 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.