1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\KernelInterface;
class KernelSubscriber implements EventSubscriberInterface
{
/**
* @var EntityManager
*/
private $entityManager;
/**
* @var KernelInterface
*/
private $kernel;
public function __construct(EntityManagerInterface $entityManager, KernelInterface $kernel)
{
$this->entityManager = $entityManager;
$this->kernel = $kernel;
}
public static function getSubscribedEvents()
{
// return the subscribed events, their methods and priorities
return array(
KernelEvents::REQUEST => array(
array('log', 0),
),
);
}
public function log(GetResponseEvent $event)
{
$request = $event->getRequest();
if ($this->kernel->getEnvironment() == "dev") {
}
$request->getClientIp();
$request->getUser();
$request->getRequestUri();
}
} |
Partager