<?php
namespace OfficeBrain\Bundle\UserBundle\Event;

use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface;
use Symfony\Component\Security\Core\SecurityContext;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class AdminLogoutSuccessEvent implements LogoutSuccessHandlerInterface
{
    private $security;
    private $router;

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

    public function onLogoutSuccess(Request $request)
    {
		// prevent caching
		/*header("Cache-Control", "no-cache, private, max-age=0");
		header("Pragma", "no-cache");
		header("X-Accel-Expires", "0");*/
    	return new RedirectResponse($this->router->generate('office_brain_userbundle_login_admin_login'));
    }
}
