<?php
namespace App\EventSubscriber;
use App\Entity\User;
use App\Security\SecurityWrapper;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
class RMQAccessControlSubscriber implements EventSubscriberInterface
{
/**
* @var SecurityWrapper
*/
private $security;
/**
* @var EntityManagerInterface
*/
private $em;
/**
* @var LoggerInterface
*/
private $logger;
/**
*
*/
public function __construct(
SecurityWrapper $security,
EntityManagerInterface $em,
LoggerInterface $logger
) {
$this->security = $security;
$this->logger = $logger;
$this->em = $em;
}
public function onKernelController(ControllerEvent $event)
{
return;
$user = $this->security->basicGetUser();
$this->logger->info("################## Access control rmq begin ################");
if (is_null($user)) {
return;
}
if (!($user instanceof User)) {
return;
}
if ($user->rmqConfigExit()) {
return;
}
$config = $user->rmqConfigExit();
if (
is_array($config) &&
$config[""]
) {
}
$user->setRmqConfig();
$this->em->flush();
$this->logger->info("################## Access control rmq end success ################");
}
public static function getSubscribedEvents()
{
return [
'kernel.controller' => 'onKernelController',
];
}
}