<?php

namespace Site\FrontendBundle\Listener;

use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Router;

class LoginListener
{
    private $router;

    public function __construct(Router $router)
    {
        $this->router = $router;
    }

    public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
    {
        $user = $event->getAuthenticationToken()->getUser();
        $user->setLastConnection(new \DateTime());
    }

    public function onKernelResponse(FilterResponseEvent $event)
    {
        //$home = $this->router->generate('home');

        //$event->setResponse(new RedirectResponse($home));
    }
}

?>