1313
1414namespace CleverAge \UiProcessBundle \Entity ;
1515
16+ use Doctrine \DBAL \Types \Types ;
1617use Doctrine \ORM \Mapping as ORM ;
1718use Symfony \Component \Security \Core \User \PasswordAuthenticatedUserInterface ;
1819use Symfony \Component \Security \Core \User \UserInterface ;
1920
2021#[ORM \Entity]
2122#[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 ' ] )]
2324class User implements UserInterface, PasswordAuthenticatedUserInterface
2425{
2526 #[ORM \Id]
2627 #[ORM \GeneratedValue]
2728 #[ORM \Column]
2829 private ?int $ id = null ;
2930
30- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , unique: true )]
31+ #[ORM \Column(type: Types::STRING , length: 255 , unique: true )]
3132 private ?string $ email = null ;
3233
33- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
34+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
3435 private ?string $ firstname = null ;
3536
36- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
37+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
3738 private ?string $ lastname = null ;
3839
39- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::JSON )]
40+ #[ORM \Column(type: Types::JSON )]
4041 private array $ roles = [];
4142
42- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
43+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
4344 private ?string $ password = null ;
4445
45- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
46+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
4647 private ?string $ timezone = null ;
4748
48- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
49+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
4950 private ?string $ locale = null ;
5051
51- #[ORM \Column(type: \ Doctrine \ DBAL \ Types \ Types::STRING , length: 255 , nullable: true )]
52+ #[ORM \Column(type: Types::STRING , length: 255 , nullable: true )]
5253 private ?string $ token = null ;
5354
5455 public function getId (): ?int
@@ -92,14 +93,13 @@ public function setLastname(?string $lastname): self
9293 return $ this ;
9394 }
9495
95- /**
96- * A visual identifier that represents this user.
97- *
98- * @see UserInterface
99- */
10096 public function getUserIdentifier (): string
10197 {
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 ;
103103 }
104104
105105 public function getUsername (): string
@@ -131,16 +131,13 @@ public function setLocale(?string $locale): self
131131 return $ this ;
132132 }
133133
134- /**
135- * @see UserInterface
136- */
137134 public function getRoles (): array
138135 {
139136 return array_merge (['ROLE_USER ' ], $ this ->roles );
140137 }
141138
142139 /**
143- * @param array <int, string> $roles
140+ * @param array<int, string> $roles
144141 */
145142 public function setRoles (array $ roles ): self
146143 {
@@ -149,9 +146,6 @@ public function setRoles(array $roles): self
149146 return $ this ;
150147 }
151148
152- /**
153- * @see PasswordAuthenticatedUserInterface
154- */
155149 public function getPassword (): ?string
156150 {
157151 return $ this ->password ;
@@ -176,20 +170,6 @@ public function setToken(?string $token): self
176170 return $ this ;
177171 }
178172
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- */
193173 public function eraseCredentials (): void
194174 {
195175 // If you store any temporary, sensitive data on the user, clear it here
0 commit comments