Completed
Push — master ( d4e81f...550fff )
by Chad
05:10
created

LoadUserEvent::getLdapObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
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 LdapTools\Bundle\LdapToolsBundle\Security\User\LdapUser;
14
use LdapTools\Object\LdapObject;
15
use Symfony\Component\EventDispatcher\Event;
16
use Symfony\Component\Security\Core\User\UserInterface;
17
18
/**
19
 * Represents a User load event.
20
 *
21
 * @author Chad Sikorra <[email protected]>
22
 */
23
class LoadUserEvent extends Event
24
{
25
    /**
26
     * The event name that happens before a user is loaded from the user provider.
27
     */
28
    const BEFORE = 'ldap_tools_bundle.load_user.before';
29
30
    /**
31
     * The event name that happens after a user is loaded from the user provider.
32
     */
33
    const AFTER = 'ldap_tools_bundle.load_user.after';
34
35
    /**
36
     * @var string
37
     */
38
    protected $username;
39
40
    /**
41
     * @var string
42
     */
43
    protected $domain;
44
45
    /**
46
     * @var UserInterface|LdapUser|null
47
     */
48
    protected $user;
49
50
    /**
51
     * @var LdapObject|null
52
     */
53
    protected $ldapObject;
54
55
    /**
56
     * @param $username
57
     * @param $domain
58
     * @param UserInterface|null $user
59
     * @param LdapObject|null $ldapObject
60
     */
61
    public function __construct($username, $domain, UserInterface $user = null, LdapObject $ldapObject = null)
62
    {
63
        $this->username = $username;
64
        $this->domain = $domain;
65
        $this->user = $user;
66
        $this->ldapObject = $ldapObject;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getUsername()
73
    {
74
        return $this->username;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getDomain()
81
    {
82
        return $this->domain;
83
    }
84
85
    /**
86
     * This is only available on an AFTER load event. Otherwise it will be null.
87
     *
88
     * @return LdapUser|null|UserInterface
89
     */
90
    public function getUser()
91
    {
92
        return $this->user;
93
    }
94
95
    /**
96
     * Get the LDAP object the user was created from. This is only available on an AFTER load event.
97
     *
98
     * @return LdapObject|null
99
     */
100
    public function getLdapObject()
101
    {
102
        return $this->ldapObject;
103
    }
104
}
105