vendor/bluue/adelya-bundle/src/EventSubscriber/ConfigurationMenuSubscriber.php line 41

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Bluue\AdelyaBundle\EventSubscriber;
  4. use App\Event\MenuConfigurationPageEvent;
  5. use Symfony\Component\Security\Core\Security;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ConfigurationMenuSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var Security
  11.      */
  12.     private Security $security;
  13.     /**
  14.      * @param Security $security
  15.      */
  16.     public function __construct(
  17.         Security $security
  18.     ) {
  19.         $this->security $security;
  20.     }
  21.     /**
  22.      * @return string[]
  23.      */
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             MenuConfigurationPageEvent::NAME => 'onLoad'
  28.         ];
  29.     }
  30.     /**
  31.      * @param MenuConfigurationPageEvent $event
  32.      * @return void
  33.      */
  34.     public function onLoad(MenuConfigurationPageEvent $event): void
  35.     {
  36.         if ($this->security->isGranted('ROLE__CASH_REGISTER__ADMIN')) {
  37.             $pages $event->getPages();
  38.             foreach ($pages as $key => $value) {
  39.                 if ($value['id'] == 'cash_register_bundle__configuration_settings') {
  40.                     $pages[$key]['subpages'][] = ['id' => 'adelya_bundle__configuration_settings'];
  41.                 }
  42.             }
  43.             $event->setPages($pages);
  44.         }
  45.     }
  46. }