<?php
namespace Aqarmap\Bundle\NeighborhoodBundle\EventListener;
use Aqarmap\Bundle\MainBundle\Event\ConfigureMenuEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class ConfigureMenuEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
{
protected ContainerInterface $container;
protected TranslatorInterface $translator;
private AuthorizationCheckerInterface $authorizationChecker;
public function __construct(ContainerInterface $container, TranslatorInterface $translator, AuthorizationCheckerInterface $authorizationChecker)
{
$this->container = $container;
$this->translator = $translator;
$this->authorizationChecker = $authorizationChecker;
}
public function onAdminSidebarMenuConfigure(ConfigureMenuEvent $event): void
{
$menu = $event->getMenu();
if ($this->authorizationChecker->isGranted('ROLE_DISCUSSION')) {
$menu['know_more']
->addChild('discussions', ['route' => 'admin_discussion_list'])
->setLabel($this->translator->trans('layout.admin.discussion'))
->setExtra('icon', 'comment-alt')
->setExtra('position', 71);
$menu['know_more']
->addChild('discussionCategories', ['route' => 'admin_discussion_categories_index'])
->setLabel($this->translator->trans('layout.admin.discussion_categories'))
->setExtra('icon', 'sitemap')
->setExtra('position', 72);
$menu['know_more']
->addChild('comments', ['route' => 'admin_comment_list'])
->setLabel($this->translator->trans('layout.admin.comment'))
->setExtra('icon', 'comments')
->setExtra('position', 73);
}
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return ['aqarmap.main.admin_sidebar_menu_configure' => 'onAdminSidebarMenuConfigure'];
}
}