|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Entité User. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP Version 5 |
|
6
|
|
|
* |
|
7
|
|
|
* @author Quétier Laurent <[email protected]> |
|
8
|
|
|
* @copyright 2014 Dev-Int GLSR |
|
9
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
10
|
|
|
* |
|
11
|
|
|
* @version since 1.0.0 |
|
12
|
|
|
* |
|
13
|
|
|
* @link https://github.com/Dev-Int/glsr |
|
14
|
|
|
*/ |
|
15
|
|
|
namespace AppBundle\Entity; |
|
16
|
|
|
|
|
17
|
|
|
use FOS\UserBundle\Model\User as BaseUser; |
|
18
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
19
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
20
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Entité User. |
|
24
|
|
|
* |
|
25
|
|
|
* @category Entity |
|
26
|
|
|
* |
|
27
|
|
|
* @ORM\Entity |
|
28
|
|
|
* @ORM\Table(name="fos_user") |
|
29
|
|
|
* @UniqueEntity(fields="usernameCanonical", errorPath="username", |
|
30
|
|
|
* message="fos_user.username.already_used", groups={"Default", "Registration", "Profile"}) |
|
31
|
|
|
* @UniqueEntity(fields="emailCanonical", errorPath="email", |
|
32
|
|
|
* message="fos_user.email.already_used", groups={"Default", "Registration", "Profile"}) |
|
33
|
|
|
*/ |
|
34
|
|
|
class User extends BaseUser |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @ORM\Id |
|
38
|
|
|
* @ORM\Column(type="integer") |
|
39
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $id; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Group", inversedBy="users") |
|
45
|
|
|
* @ORM\JoinTable(name="fos_user_user_group", |
|
46
|
|
|
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}, |
|
47
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")} |
|
48
|
|
|
* ) |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $groups; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @ORM\Column(type="integer", length=6, options={"default":0}) |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $loginCount = 0; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var \DateTime |
|
59
|
|
|
* |
|
60
|
|
|
* @ORM\Column(type="datetime", nullable=true) |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $firstLogin; |
|
63
|
|
|
|
|
64
|
|
|
public function __construct() |
|
65
|
|
|
{ |
|
66
|
|
|
parent::__construct(); |
|
67
|
|
|
$this->groups = new ArrayCollection(); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Set loginCount |
|
72
|
|
|
* |
|
73
|
|
|
* @param integer $loginCount |
|
74
|
|
|
* |
|
75
|
|
|
* @return User |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setLoginCount($loginCount) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->loginCount = $loginCount; |
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Get loginCount |
|
85
|
|
|
* |
|
86
|
|
|
* @return integer |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getLoginCount() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->loginCount; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Set firstLogin |
|
95
|
|
|
* |
|
96
|
|
|
* @param \DateTime $firstLogin |
|
97
|
|
|
* |
|
98
|
|
|
* @return User |
|
99
|
|
|
*/ |
|
100
|
|
|
public function setFirstLogin($firstLogin) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->firstLogin = $firstLogin; |
|
103
|
|
|
return $this; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Get firstLogin |
|
108
|
|
|
* |
|
109
|
|
|
* @return \DateTime |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getFirstLogin() |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->firstLogin; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function getEnabled() |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->enabled; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function getLocked() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->locked; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function getExpired() |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->expired; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function getExpiresAt() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->expiresAt; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function getCredentialsExpired() |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->credentialsExpired; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function getCredentialsExpireAt() |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->credentialsExpireAt; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function setSalt($salt) |
|
147
|
|
|
{ |
|
148
|
|
|
$this->salt = $salt; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
public function setPassword($password) |
|
152
|
|
|
{ |
|
153
|
|
|
if ($password !== null) { |
|
154
|
|
|
$this->password = $password; |
|
155
|
|
|
} |
|
156
|
|
|
return $this; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function setGroups(ArrayCollection $groups = null) |
|
160
|
|
|
{ |
|
161
|
|
|
if ($groups !== null) { |
|
162
|
|
|
$this->groups = $groups; |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
public function setRoles(array $roles = array()) |
|
167
|
|
|
{ |
|
168
|
|
|
$this->roles = array(); |
|
169
|
|
|
foreach ($roles as $role) { |
|
170
|
|
|
$this->addRole($role); |
|
171
|
|
|
} |
|
172
|
|
|
return $this; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
public function hasGroup($name = '') |
|
176
|
|
|
{ |
|
177
|
|
|
return in_array($name, $this->getGroupNames()); |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|