vendor/bluue/tickets-bundle/src/EventSubscriber/ConfigureSubMenuSubscriber.php line 56

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Quentin CHATELAIN (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace Bluue\TicketsBundle\EventSubscriber;
  9. use App\Event\MenuConfigurationPageEvent;
  10. use Symfony\Component\Security\Core\Security;
  11. use Symfony\Contracts\Translation\TranslatorInterface;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. class ConfigureSubMenuSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @var TranslatorInterface
  17.      */
  18.     private TranslatorInterface $tr;
  19.     /**
  20.      * @var Security
  21.      */
  22.     private Security $security;
  23.     /**
  24.      * @param TranslatorInterface $tr
  25.      * @param Security $security
  26.      */
  27.     public function __construct(
  28.         TranslatorInterface $tr,
  29.         Security $security
  30.     ) {
  31.         $this->tr $tr;
  32.         $this->security $security;
  33.     }
  34.     /**
  35.      * @return string[]
  36.      */
  37.     public static function getSubscribedEvents(): array
  38.     {
  39.         return [
  40.             MenuConfigurationPageEvent::NAME => 'onLoad'
  41.         ];
  42.     }
  43.     /**
  44.      * @param MenuConfigurationPageEvent $event
  45.      * @return void
  46.      */
  47.     public function onLoad(MenuConfigurationPageEvent $event): void
  48.     {
  49.         if ($this->security->isGranted('ROLE__TICKETS__ADMIN')) {
  50.             $pages $event->getPages();
  51.             $pages[] = [
  52.                 'id' => 'tickets_bundle__configuration_settings',
  53.                 'name' => $this->tr->trans('Tickets Module', [], 'TicketsBundle'),
  54.                 'subpages' => [
  55.                     ['id' => 'tickets_bundle__configuration_settings'],
  56.                     ['id' => 'tickets_bundle__configuration_ticket_state_list'],
  57.                     ['id' => 'tickets_bundle__configuration_predefined_message_list'],
  58.                     ['id' => 'tickets_bundle__configuration_predefined_message_status_change_list'],
  59.                     ['id' => 'tickets_bundle__configuration_relaunch_list'],
  60.                     ['id' => 'tickets_bundle__configuration_mail_server'],
  61.                     ['id' => 'tickets_bundle__configuration_tags'],
  62.                     ['id' => 'tickets_bundle__closing_motifs_list']
  63.                 ]
  64.             ];
  65.             $event->setPages($pages);
  66.         }
  67.     }
  68. }