<?php
namespace App\EventSubscriber;
use App\Service\DadataClientInterface;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use MLDev\SeoSiteBundle\Service\SiteManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class GeoLocationSubscriber implements EventSubscriberInterface
{
private $siteManager;
private $entityManager;
private $dadataClient;
public function __construct(
EntityManagerInterface $entityManager,
SiteManager $siteManager,
DadataClientInterface $dadataClient
) {
$this->siteManager = $siteManager;
$this->entityManager = $entityManager;
$this->dadataClient = $dadataClient;
}
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => ['onKernelRequest', 110],
];
}
public function onKernelRequest(RequestEvent $event)
{
if (!$event->isMainRequest()) {
return;
}
// dump(
// $this->dadataClient->iplocate(
// $event->getRequest()->getClientIp()
// )
// );
}
}