1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Security\Http\Event;
13
14use Symfony\Component\EventDispatcher\Event;
15use Symfony\Component\HttpFoundation\Request;
16use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17use Symfony\Component\Security\Core\User\UserInterface;
18
19/**
20 * SwitchUserEvent.
21 *
22 * @author Fabien Potencier <fabien@symfony.com>
23 */
24class SwitchUserEvent extends Event
25{
26    private $request;
27    private $targetUser;
28    private $token;
29
30    public function __construct(Request $request, UserInterface $targetUser, TokenInterface $token = null)
31    {
32        $this->request = $request;
33        $this->targetUser = $targetUser;
34        $this->token = $token;
35    }
36
37    /**
38     * @return Request
39     */
40    public function getRequest()
41    {
42        return $this->request;
43    }
44
45    /**
46     * @return UserInterface
47     */
48    public function getTargetUser()
49    {
50        return $this->targetUser;
51    }
52
53    /**
54     * @return TokenInterface|null
55     */
56    public function getToken()
57    {
58        return $this->token;
59    }
60
61    public function setToken(TokenInterface $token)
62    {
63        $this->token = $token;
64    }
65}
66