Completed
Push — master ( 4fff23...13399c )
by Kamil
30:31
created

BackendMenuBuilder::addAssortmentMenu()   C

Complexity

Conditions 8
Paths 128

Size

Total Lines 57
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 57
rs 6.4931
cc 8
eloc 40
nc 128
nop 3

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\WebBundle\Menu;
13
14
use Knp\Menu\ItemInterface;
15
use Sylius\Bundle\WebBundle\Event\MenuBuilderEvent;
16
17
/**
18
 * Main menu builder.
19
 *
20
 * @author Paweł Jędrzejewski <[email protected]>
21
 */
22
class BackendMenuBuilder extends MenuBuilder
23
{
24
    /**
25
     * Builds backend main menu.
26
     *
27
     * @return ItemInterface
28
     */
29
    public function createMainMenu()
30
    {
31
        $menu = $this->factory->createItem('root', [
32
            'childrenAttributes' => [
33
                'class' => 'nav navbar-nav navbar-right',
34
            ],
35
        ]);
36
37
        $childOptions = [
38
            'attributes' => ['class' => 'dropdown'],
39
            'childrenAttributes' => ['class' => 'dropdown-menu'],
40
            'labelAttributes' => ['class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'href' => '#'],
41
        ];
42
43
        $menu->addChild('dashboard', [
44
            'route' => 'sylius_backend_dashboard',
45
        ])->setLabel($this->translate('sylius.backend.menu.main.dashboard'));
46
47
        $this->addAssortmentMenu($menu, $childOptions, 'main');
48
        $this->addSalesMenu($menu, $childOptions, 'main');
49
        $this->addCustomerMenu($menu, $childOptions, 'main');
50
        $this->addMarketingMenu($menu, $childOptions, 'main');
51
        $this->addSupportMenu($menu, $childOptions, 'main');
52
        $this->addContentMenu($menu, $childOptions, 'main');
53
        $this->addConfigurationMenu($menu, $childOptions, 'main');
54
        $this->addReviewsMenu($menu, $childOptions, 'main');
55
56
        $menu->addChild('homepage', [
57
            'route' => 'sylius_homepage',
58
        ])->setLabel($this->translate('sylius.backend.menu.main.homepage'));
59
60
        $menu->addChild('logout', [
61
            'route' => 'sylius_user_security_logout',
62
        ])->setLabel($this->translate('sylius.backend.logout'));
63
64
        $this->eventDispatcher->dispatch(MenuBuilderEvent::BACKEND_MAIN, new MenuBuilderEvent($this->factory, $menu));
65
66
        return $menu;
67
    }
68
69
    /**
70
     * Builds backend sidebar menu.
71
     *
72
     * @return ItemInterface
73
     */
74
    public function createSidebarMenu()
75
    {
76
        $menu = $this->factory->createItem('root', [
77
            'childrenAttributes' => [
78
                'class' => 'nav',
79
            ],
80
        ]);
81
82
        $menu->setCurrentUri($this->request->getRequestUri());
83
84
        $childOptions = [
85
            'childrenAttributes' => ['class' => 'nav'],
86
            'labelAttributes' => ['class' => 'nav-header'],
87
        ];
88
89
        $this->addAssortmentMenu($menu, $childOptions, 'sidebar');
90
        $this->addSalesMenu($menu, $childOptions, 'sidebar');
91
        $this->addMarketingMenu($menu, $childOptions, 'sidebar');
92
        $this->addCustomerMenu($menu, $childOptions, 'sidebar');
93
        $this->addSupportMenu($menu, $childOptions, 'sidebar');
94
        $this->addContentMenu($menu, $childOptions, 'sidebar');
95
        $this->addReviewsMenu($menu, $childOptions, 'sidebar');
96
97
        $this->addConfigurationMenu($menu, $childOptions, 'sidebar');
98
99
        $this->eventDispatcher->dispatch(MenuBuilderEvent::BACKEND_SIDEBAR, new MenuBuilderEvent($this->factory, $menu));
100
101
        return $menu;
102
    }
103
104
    /**
105
     * Add assortment menu.
106
     *
107
     * @param ItemInterface $menu
108
     * @param array         $childOptions
109
     * @param string        $section
110
     */
111
    protected function addAssortmentMenu(ItemInterface $menu, array $childOptions, $section)
112
    {
113
        $child = $menu
114
            ->addChild('assortment', $childOptions)
115
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.assortment', $section)))
116
        ;
117
118
        if ($this->rbacAuthorizationChecker->isGranted('sylius.taxonomy.index')) {
119
            $child->addChild('taxonomies', [
120
                'route' => 'sylius_backend_taxonomy_index',
121
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-folder-close'],
122
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.taxonomies', $section)));
123
        }
124
125
        if ($this->rbacAuthorizationChecker->isGranted('sylius.product.index')) {
126
            $child->addChild('products', [
127
                'route' => 'sylius_backend_product_index',
128
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-th-list'],
129
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.products', $section)));
130
            $child->addChild('inventory', [
131
                'route' => 'sylius_backend_inventory_index',
132
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-tasks'],
133
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.stockables', $section)));
134
        }
135
136
        if ($this->rbacAuthorizationChecker->isGranted('sylius.product_option.index')) {
137
            $child->addChild('options', [
138
                'route' => 'sylius_backend_product_option_index',
139
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-th'],
140
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.options', $section)));
141
        }
142
143
        if ($this->rbacAuthorizationChecker->isGranted('sylius.product_attribute.index')) {
144
            $child->addChild('product_attributes', [
145
                'route' => 'sylius_backend_product_attribute_index',
146
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-list-alt'],
147
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.attributes', $section)));
148
        }
149
150
        if ($this->rbacAuthorizationChecker->isGranted('sylius.product_archetype.index')) {
151
            $child->addChild('product_archetypes', [
152
                'route' => 'sylius_backend_product_archetype_index',
153
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-compressed'],
154
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.archetypes', $section)));
155
        }
156
157
        if (!$child->hasChildren()) {
158
            $menu->removeChild('assortment');
159
        }
160
161
        if ($this->rbacAuthorizationChecker->isGranted('sylius.product_association_type.index')) {
162
            $child->addChild('product_association types', [
163
                'route' => 'sylius_backend_product_association_type_index',
164
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-th-list'],
165
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.association_types', $section)));
166
        }
167
    }
168
169
    /**
170
     * Add content menu.
171
     *
172
     * @param ItemInterface $menu
173
     * @param array         $childOptions
174
     * @param string        $section
175
     */
176
    protected function addContentMenu(ItemInterface $menu, array $childOptions, $section)
177
    {
178
        $child = $menu
179
            ->addChild('content', $childOptions)
180
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.content', $section)))
181
        ;
182
183
        if ($this->rbacAuthorizationChecker->isGranted('sylius.simple_block.index')) {
184
            $child->addChild('blocks', [
185
                'route' => 'sylius_backend_block_overview',
186
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-th-large'],
187
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.blocks', $section)));
188
        }
189
        if ($this->rbacAuthorizationChecker->isGranted('sylius.static_content.index')) {
190
            $child->addChild('Pages', [
191
                'route' => 'sylius_backend_static_content_index',
192
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-file'],
193
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.pages', $section)));
194
        }
195
        if ($this->rbacAuthorizationChecker->isGranted('sylius.menu.index')) {
196
            $child->addChild('Menus', [
197
                'route' => 'sylius_backend_menu_index',
198
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-list-alt'],
199
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.menus', $section)));
200
        }
201
        if ($this->rbacAuthorizationChecker->isGranted('sylius.slideshow.index')) {
202
            $child->addChild('Slideshow', [
203
                'route' => 'sylius_backend_slideshow_block_index',
204
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-film'],
205
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.slideshow', $section)));
206
        }
207
        if ($this->rbacAuthorizationChecker->isGranted('sylius.route.index')) {
208
            $child->addChild('Routes', [
209
                'route' => 'sylius_backend_route_index',
210
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-random'],
211
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.routes', $section)));
212
        }
213
214
        if (!$child->hasChildren()) {
215
            $menu->removeChild('content');
216
        }
217
    }
218
219
    /**
220
     * Add marketing menu.
221
     *
222
     * @param ItemInterface $menu
223
     * @param array         $childOptions
224
     * @param string        $section
225
     */
226
    protected function addMarketingMenu(ItemInterface $menu, array $childOptions, $section)
227
    {
228
        $child = $menu
229
            ->addChild('marketing', $childOptions)
230
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.marketing', $section)))
231
        ;
232
233
        if ($this->rbacAuthorizationChecker->isGranted('sylius.promotion.index')) {
234
            $child->addChild('promotions', [
235
                'route' => 'sylius_backend_promotion_index',
236
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-bullhorn'],
237
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.promotions', $section)));
238
        }
239
        if ($this->rbacAuthorizationChecker->isGranted('sylius.promotion.create')) {
240
            $child->addChild('new_promotion', [
241
                'route' => 'sylius_backend_promotion_create',
242
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-plus-sign'],
243
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.new_promotion', $section)));
244
        }
245
        if ($this->rbacAuthorizationChecker->isGranted('sylius.manage.email')) {
246
            $child->addChild('emails', [
247
                'route' => 'sylius_backend_email_index',
248
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-envelope'],
249
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.emails', $section)));
250
        }
251
252
        if (!$child->hasChildren()) {
253
            $menu->removeChild('marketing');
254
        }
255
    }
256
257
    /**
258
     * Add support menu.
259
     *
260
     * @param ItemInterface $menu
261
     * @param array         $childOptions
262
     * @param string        $section
263
     */
264
    protected function addSupportMenu(ItemInterface $menu, array $childOptions, $section)
265
    {
266
        $child = $menu
267
            ->addChild('support', $childOptions)
268
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.support', $section)))
269
        ;
270
271
        if ($this->rbacAuthorizationChecker->isGranted('sylius.contact_request.index')) {
272
            $child->addChild('contact_requests', [
273
                'route' => 'sylius_backend_contact_request_index',
274
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-envelope'],
275
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.contact_requests', $section)));
276
        }
277
        if ($this->rbacAuthorizationChecker->isGranted('sylius.contact_topic.index')) {
278
            $child->addChild('contact_topics', [
279
                'route' => 'sylius_backend_contact_topic_index',
280
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-align-justify'],
281
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.contact_topics', $section)));
282
        }
283
284
        if (!$child->hasChildren()) {
285
            $menu->removeChild('support');
286
        }
287
    }
288
289
    /**
290
     * Add customers menu.
291
     *
292
     * @param ItemInterface $menu
293
     * @param array         $childOptions
294
     * @param string        $section
295
     */
296
    protected function addCustomerMenu(ItemInterface $menu, array $childOptions, $section)
297
    {
298
        $child = $menu
299
            ->addChild('customer', $childOptions)
300
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.customer', $section)))
301
        ;
302
303
        if ($this->rbacAuthorizationChecker->isGranted('sylius.customer.index')) {
304
            $child->addChild('customers', [
305
                'route' => 'sylius_backend_customer_index',
306
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-user'],
307
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.customers', $section)));
308
        }
309
        if ($this->rbacAuthorizationChecker->isGranted('sylius.group.index')) {
310
            $child->addChild('groups', [
311
                'route' => 'sylius_backend_group_index',
312
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-home'],
313
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.groups', $section)));
314
        }
315
        if ($this->rbacAuthorizationChecker->isGranted('sylius.role.index')) {
316
            $child->addChild('roles', [
317
                'route' => 'sylius_backend_role_index',
318
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-sort-by-attributes'],
319
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.roles', $section)));
320
        }
321
        if ($this->rbacAuthorizationChecker->isGranted('sylius.permission.index')) {
322
            $child->addChild('permissions', [
323
                'route' => 'sylius_backend_permission_index',
324
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-lock'],
325
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.permissions', $section)));
326
        }
327
328
        if (!$child->hasChildren()) {
329
            $menu->removeChild('customer');
330
        }
331
    }
332
333
    /**
334
     * Add sales menu.
335
     *
336
     * @param ItemInterface $menu
337
     * @param array         $childOptions
338
     * @param string        $section
339
     */
340
    protected function addSalesMenu(ItemInterface $menu, array $childOptions, $section)
341
    {
342
        $child = $menu
343
            ->addChild('sales', $childOptions)
344
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.sales', $section)))
345
        ;
346
347
        if ($this->rbacAuthorizationChecker->isGranted('sylius.order.index')) {
348
            $child->addChild('orders', [
349
                'route' => 'sylius_backend_order_index',
350
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-shopping-cart'],
351
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.orders', $section)));
352
        }
353
        if ($this->rbacAuthorizationChecker->isGranted('sylius.shipment.index')) {
354
            $child->addChild('shipments', [
355
                'route' => 'sylius_backend_shipment_index',
356
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-plane'],
357
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.shipments', $section)));
358
        }
359
        if ($this->rbacAuthorizationChecker->isGranted('sylius.payment.index')) {
360
            $child->addChild('payments', [
361
                'route' => 'sylius_backend_payment_index',
362
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-credit-card'],
363
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.payments', $section)));
364
        }
365
        if ($this->rbacAuthorizationChecker->isGranted('sylius.report.index')) {
366
            $child->addChild('reports', [
367
                'route' => 'sylius_backend_report_index',
368
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-stats'],
369
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.report', $section)));
370
        }
371
372
        if (!$child->hasChildren()) {
373
            $menu->removeChild('sales');
374
        }
375
    }
376
377
    /**
378
     * @param ItemInterface $menu
379
     * @param array $childOptions
380
     * @param string $section
381
     */
382
    public function addReviewsMenu(ItemInterface $menu, array $childOptions, $section)
383
    {
384
        $child = $menu
385
            ->addChild('review', $childOptions)
386
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.review', $section)))
387
        ;
388
389
        $child->addChild('reviews', [
390
            'route' => 'sylius_backend_product_review_index',
391
            'labelAttributes' => ['icon' => 'glyphicon glyphicon-pencil'],
392
        ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.product_review', $section)));
393
    }
394
395
    /**
396
     * Add configuration menu.
397
     *
398
     * @param ItemInterface $menu
399
     * @param array         $childOptions
400
     * @param string        $section
401
     */
402
    protected function addConfigurationMenu(ItemInterface $menu, array $childOptions, $section)
403
    {
404
        $child = $menu
405
            ->addChild('configuration', $childOptions)
406
            ->setLabel($this->translate(sprintf('sylius.backend.menu.%s.configuration', $section)))
407
        ;
408
409
        if ($this->rbacAuthorizationChecker->isGranted('sylius.settings.sylius_general')) {
410
            $child->addChild('general_settings', [
411
                'route' => 'sylius_backend_general_settings',
412
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-info-sign'],
413
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.general_settings', $section)));
414
        }
415
416
        if ($this->rbacAuthorizationChecker->isGranted('sylius.settings.sylius_security')) {
417
            $child->addChild('security_settings', [
418
                'route' => 'sylius_backend_security_settings',
419
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-lock'],
420
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.security_settings', $section)));
421
        }
422
423
        if ($this->rbacAuthorizationChecker->isGranted('sylius.channel.index')) {
424
            $child->addChild('channels', [
425
                'route' => 'sylius_backend_channel_index',
426
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-cog'],
427
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.channels', $section)));
428
        }
429
430
        if ($this->rbacAuthorizationChecker->isGranted('sylius.metadata_container.index')) {
431
            $child->addChild('metadata', [
432
                'route' => 'sylius_backend_metadata_container_index',
433
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-file'],
434
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.metadata', $section)));
435
        }
436
437
        if ($this->rbacAuthorizationChecker->isGranted('sylius.locale.index')) {
438
            $child->addChild('locales', [
439
                'route' => 'sylius_backend_locale_index',
440
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-flag'],
441
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.locales', $section)));
442
        }
443
444
        if ($this->rbacAuthorizationChecker->isGranted('sylius.payment_method.index')) {
445
            $child->addChild('payment_methods', [
446
                'route' => 'sylius_backend_payment_method_index',
447
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-credit-card'],
448
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.payment_methods', $section)));
449
        }
450
451
        if ($this->rbacAuthorizationChecker->isGranted('sylius.currency.index')) {
452
            $child->addChild('currencies', [
453
                'route' => 'sylius_backend_currency_index',
454
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-usd'],
455
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.currencies', $section)));
456
        }
457
458
        if ($this->rbacAuthorizationChecker->isGranted('sylius.settings.sylius_taxation')) {
459
            $child->addChild('taxation_settings', [
460
                'route' => 'sylius_backend_taxation_settings',
461
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-cog'],
462
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.taxation_settings', $section)));
463
        }
464
465
        if ($this->rbacAuthorizationChecker->isGranted('sylius.tax_category.index')) {
466
            $child->addChild('tax_categories', [
467
                'route' => 'sylius_backend_tax_category_index',
468
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-cog'],
469
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.tax_categories', $section)));
470
        }
471
472
        if ($this->rbacAuthorizationChecker->isGranted('sylius.tax_rate.index')) {
473
            $child->addChild('tax_rates', [
474
                'route' => 'sylius_backend_tax_rate_index',
475
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-cog'],
476
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.tax_rates', $section)));
477
        }
478
479
        if ($this->rbacAuthorizationChecker->isGranted('sylius.shipping_category.index')) {
480
            $child->addChild('shipping_categories', [
481
                'route' => 'sylius_backend_shipping_category_index',
482
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-cog'],
483
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.shipping_categories', $section)));
484
        }
485
486
        if ($this->rbacAuthorizationChecker->isGranted('sylius.shipping_method.index')) {
487
            $child->addChild('shipping_methods', [
488
                'route' => 'sylius_backend_shipping_method_index',
489
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-cog'],
490
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.shipping_methods', $section)));
491
        }
492
493
        if ($this->rbacAuthorizationChecker->isGranted('sylius.country.index')) {
494
            $child->addChild('countries', [
495
                'route' => 'sylius_backend_country_index',
496
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-flag'],
497
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.countries', $section)));
498
        }
499
500
        if ($this->rbacAuthorizationChecker->isGranted('sylius.zone.index')) {
501
            $child->addChild('zones', [
502
                'route' => 'sylius_backend_zone_index',
503
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-globe'],
504
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.zones', $section)));
505
        }
506
507
        if ($this->rbacAuthorizationChecker->isGranted('sylius.api_client.index')) {
508
            $child->addChild('api_clients', [
509
                'route' => 'sylius_backend_api_client_index',
510
                'labelAttributes' => ['icon' => 'glyphicon glyphicon-globe'],
511
            ])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.api_clients', $section)));
512
        }
513
514
        if (!$child->hasChildren()) {
515
            $menu->removeChild('configuration');
516
        }
517
    }
518
}
519