<?php
namespace App\EventSubscriber;
use App\Controller\AppBundle\Helpers\Admin\ConsultantHelper;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class SentrySubscriber implements EventSubscriberInterface
{
private $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function onKernelController(ControllerEvent $event)
{
$controller = $event->getController();
$consultant = ConsultantHelper::getLoggedInConsultant($event->getRequest(), $this->em);
if ($consultant !== false) {
// \Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($consultant): void {
// $scope->setUser(['username' => $consultant->getUsername()]);
// });
}
}
public static function getSubscribedEvents()
{
return [
KernelEvents::CONTROLLER => 'onKernelController',
];
}
}