src/EventSubscriber/SentrySubscriber.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Controller\AppBundle\Helpers\Admin\ConsultantHelper;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  7. use Symfony\Component\HttpKernel\KernelEvents;
  8. class SentrySubscriber implements EventSubscriberInterface
  9. {
  10.     private $em;
  11.     public function __construct(EntityManagerInterface $em)
  12.     {
  13.         $this->em $em;
  14.     }
  15.     public function onKernelController(ControllerEvent $event)
  16.     {
  17.         $controller $event->getController();
  18.             $consultant ConsultantHelper::getLoggedInConsultant($event->getRequest(), $this->em);
  19.             if ($consultant !== false) {
  20. //                \Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($consultant): void {
  21. //                    $scope->setUser(['username' => $consultant->getUsername()]);
  22. //                });
  23.             }
  24.     }
  25.     public static function getSubscribedEvents()
  26.     {
  27.         return [
  28.             KernelEvents::CONTROLLER => 'onKernelController',
  29.         ];
  30.     }
  31. }