Completed
Push — master ( d6e668...f03e1f )
by Chad
02:01
created

AuthenticationHandlerEvent::getException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the LdapToolsBundle package.
4
 *
5
 * (c) Chad Sikorra <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LdapTools\Bundle\LdapToolsBundle\Event;
12
13
use Symfony\Component\EventDispatcher\Event;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17
18
/**
19
 * Represents an authentication handler event, such as success or failure, where the response can be set.
20
 *
21
 * @author Chad Sikorra <[email protected]>
22
 */
23
class AuthenticationHandlerEvent extends Event
24
{
25
    /**
26
     * The event name that happens after the default authentication success handler is called.
27
     */
28
    const SUCCESS = 'ldap_tools_bundle.guard.login.success';
29
30
    /**
31
     * The event name that happens after the default authentication failure handler is called.
32
     */
33
    const FAILURE = 'ldap_tools_bundle.guard.login.failure';
34
35
    /**
36
     * @var Response
37
     */
38
    protected $response;
39
40
    /**
41
     * @var \Exception|null
42
     */
43
    protected $exception;
44
45
    /**
46
     * @var Request
47
     */
48
    protected $request;
49
50
    /**
51
     * @var TokenInterface|null
52
     */
53
    protected $token;
54
55
    /**
56
     * @var string|null
57
     */
58
    protected $providerKey;
59
60
    /**
61
     * @param Response $response
62
     * @param Request $request
63
     * @param \Exception|null $exception
64
     * @param TokenInterface|null $token
65
     * @param string|null $providerKey
66
     */
67
    public function __construct(Response $response, Request $request, \Exception $exception = null, TokenInterface $token = null, $providerKey = null)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
68
    {
69
        $this->request = $request;
70
        $this->response = $response;
71
        $this->exception = $exception;
72
        $this->token = $token;
73
        $this->providerKey = $providerKey;
74
    }
75
76
    /**
77
     * @return Response
78
     */
79
    public function getResponse()
80
    {
81
        return $this->response;
82
    }
83
84
    /**
85
     * @return Request
86
     */
87
    public function getRequest()
88
    {
89
        return $this->request;
90
    }
91
92
    /**
93
     * @param Response $response
94
     * @return $this
95
     */
96
    public function setResponse(Response $response)
97
    {
98
        $this->response = $response;
99
100
        return $this;
101
    }
102
103
    /**
104
     * @return \Exception|null
105
     */
106
    public function getException()
107
    {
108
        return $this->exception;
109
    }
110
111
    /**
112
     * @return null|TokenInterface
113
     */
114
    public function getToken()
115
    {
116
        return $this->token;
117
    }
118
119
    /**
120
     * @return null|string
121
     */
122
    public function getProviderKey()
123
    {
124
        return $this->providerKey;
125
    }
126
}
127