13
13
14
14
namespace CleverAge \UiProcessBundle \Entity ;
15
15
16
+ use Doctrine \DBAL \Types \Types ;
16
17
use Doctrine \ORM \Mapping as ORM ;
17
18
use Symfony \Component \Security \Core \User \PasswordAuthenticatedUserInterface ;
18
19
use Symfony \Component \Security \Core \User \UserInterface ;
19
20
20
21
#[ORM \Entity]
21
22
#[ORM \Table(name: 'process_user ' )]
22
- #[ORM \Index(columns: [ ' email ' ], name: ' idx_process_user_email ' )]
23
+ #[ORM \Index(name: ' idx_process_user_email ' , columns: [ ' email ' ] )]
23
24
class User implements UserInterface, PasswordAuthenticatedUserInterface
24
25
{
25
26
#[ORM \Id]
26
27
#[ORM \GeneratedValue]
27
28
#[ORM \Column]
28
29
private ?int $ id = null ;
29
30
30
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , unique: true )]
31
+ #[ORM \Column(type: Types::STRING , length: 255 , unique: true )]
31
32
private ?string $ email = null ;
32
33
33
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
34
+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
34
35
private ?string $ firstname = null ;
35
36
36
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
37
+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
37
38
private ?string $ lastname = null ;
38
39
39
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::JSON )]
40
+ #[ORM \Column(type: Types::JSON )]
40
41
private array $ roles = [];
41
42
42
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
43
+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
43
44
private ?string $ password = null ;
44
45
45
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
46
+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
46
47
private ?string $ timezone = null ;
47
48
48
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
49
+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
49
50
private ?string $ locale = null ;
50
51
51
- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
52
+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
52
53
private ?string $ token = null ;
53
54
54
55
public function getId (): ?int
@@ -92,14 +93,13 @@ public function setLastname(?string $lastname): self
92
93
return $ this ;
93
94
}
94
95
95
- /**
96
- * A visual identifier that represents this user.
97
- *
98
- * @see UserInterface
99
- */
100
96
public function getUserIdentifier (): string
101
97
{
102
- return (string ) $ this ->email ;
98
+ if (null === $ this ->email || '' === $ this ->email || '0 ' === $ this ->email ) {
99
+ throw new \LogicException ('The User class must have an email. ' );
100
+ }
101
+
102
+ return $ this ->email ;
103
103
}
104
104
105
105
public function getUsername (): string
@@ -131,16 +131,13 @@ public function setLocale(?string $locale): self
131
131
return $ this ;
132
132
}
133
133
134
- /**
135
- * @see UserInterface
136
- */
137
134
public function getRoles (): array
138
135
{
139
136
return array_merge (['ROLE_USER ' ], $ this ->roles );
140
137
}
141
138
142
139
/**
143
- * @param array <int, string> $roles
140
+ * @param array<int, string> $roles
144
141
*/
145
142
public function setRoles (array $ roles ): self
146
143
{
@@ -149,9 +146,6 @@ public function setRoles(array $roles): self
149
146
return $ this ;
150
147
}
151
148
152
- /**
153
- * @see PasswordAuthenticatedUserInterface
154
- */
155
149
public function getPassword (): ?string
156
150
{
157
151
return $ this ->password ;
@@ -176,20 +170,6 @@ public function setToken(?string $token): self
176
170
return $ this ;
177
171
}
178
172
179
- /**
180
- * Returning a salt is only needed, if you are not using a modern
181
- * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
182
- *
183
- * @see UserInterface
184
- */
185
- public function getSalt (): ?string
186
- {
187
- return null ;
188
- }
189
-
190
- /**
191
- * @see UserInterface
192
- */
193
173
public function eraseCredentials (): void
194
174
{
195
175
// If you store any temporary, sensitive data on the user, clear it here
0 commit comments