-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
MenuSubscriber.php
49 lines (42 loc) · 1.38 KB
/
MenuSubscriber.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace Mautic\MarketplaceBundle\EventListener;
use Mautic\CoreBundle\CoreEvents;
use Mautic\CoreBundle\Event\MenuEvent;
use Mautic\MarketplaceBundle\Security\Permissions\MarketplacePermissions;
use Mautic\MarketplaceBundle\Service\Config;
use Mautic\MarketplaceBundle\Service\RouteProvider;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class MenuSubscriber implements EventSubscriberInterface
{
public function __construct(
private Config $config
) {
}
public static function getSubscribedEvents(): array
{
return [
CoreEvents::BUILD_MENU => ['onBuildMenu', 9999],
];
}
public function onBuildMenu(MenuEvent $event): void
{
if ('admin' !== $event->getType() || !$this->config->marketplaceIsEnabled()) {
return;
}
$event->addMenuItems(
[
'priority' => 81,
'items' => [
'marketplace.title' => [
'id' => 'marketplace',
'route' => RouteProvider::ROUTE_LIST,
'access' => MarketplacePermissions::CAN_VIEW_PACKAGES,
'parent' => 'mautic.core.integrations',
'priority' => 16,
],
],
]
);
}
}