src/EventSubscriber/RMQAccessControlSubscriber.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Entity\User;
  4. use App\Security\SecurityWrapper;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Psr\Log\LoggerInterface;
  8. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  9. class RMQAccessControlSubscriber implements EventSubscriberInterface
  10. {
  11.     /**
  12.      * @var SecurityWrapper
  13.      */
  14.     private $security;
  15.     /**
  16.      * @var EntityManagerInterface
  17.      */
  18.     private $em;
  19.     /**
  20.      * @var LoggerInterface
  21.      */
  22.     private $logger;
  23.     /**
  24.      * 
  25.      */
  26.     public function __construct(
  27.         SecurityWrapper $security
  28.         EntityManagerInterface $em,
  29.         LoggerInterface $logger
  30.     ) {
  31.         $this->security $security;
  32.         $this->logger $logger;
  33.         $this->em $em;
  34.     }
  35.     public function onKernelController(ControllerEvent $event)
  36.     {
  37.         return;
  38.         $user $this->security->basicGetUser();
  39.         $this->logger->info("################## Access control rmq begin ################");
  40.         if (is_null($user)) {
  41.             return;
  42.         }
  43.         if (!($user instanceof User)) {
  44.             return;
  45.         }
  46.         if ($user->rmqConfigExit()) {
  47.             return;
  48.         }
  49.         $config $user->rmqConfigExit();
  50.         if (
  51.             is_array($config) &&
  52.             $config[""]
  53.         ) {
  54.             
  55.         }
  56.         $user->setRmqConfig();
  57.         $this->em->flush();
  58.         $this->logger->info("################## Access control rmq end success ################");
  59.     }
  60.     public static function getSubscribedEvents()
  61.     {
  62.         return [
  63.             'kernel.controller' => 'onKernelController',
  64.         ];
  65.     }
  66. }