src/EventSubscriber/GeoLocationSubscriber.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Service\DadataClientInterface;
  4. use Doctrine\ORM\EntityManager;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use MLDev\SeoSiteBundle\Service\SiteManager;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\HttpKernel\Event\RequestEvent;
  9. use Symfony\Component\HttpKernel\KernelEvents;
  10. class GeoLocationSubscriber implements EventSubscriberInterface
  11. {
  12.     private $siteManager;
  13.     private $entityManager;
  14.     private $dadataClient;
  15.     public function __construct(
  16.         EntityManagerInterface $entityManager,
  17.         SiteManager $siteManager,
  18.         DadataClientInterface $dadataClient
  19.     ) {
  20.         $this->siteManager $siteManager;
  21.         $this->entityManager $entityManager;
  22.         $this->dadataClient $dadataClient;
  23.     }
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             KernelEvents::REQUEST => ['onKernelRequest'110],
  28.         ];
  29.     }
  30.     public function onKernelRequest(RequestEvent $event)
  31.     {
  32.         if (!$event->isMainRequest()) {
  33.             return;
  34.         }
  35. //        dump(
  36. //            $this->dadataClient->iplocate(
  37. //                $event->getRequest()->getClientIp()
  38. //            )
  39. //        );
  40.     }
  41. }