1 | <?php |
||
18 | class User implements UserInterface |
||
19 | { |
||
20 | /** |
||
21 | * @ORM\Id() |
||
22 | * @ORM\GeneratedValue() |
||
23 | * @ORM\Column(type="integer") |
||
24 | * @Groups({"list", "view"}) |
||
25 | */ |
||
26 | private $id; |
||
27 | |||
28 | /** |
||
29 | * @var $profile UserProfile |
||
30 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserProfile", cascade={"persist", "remove"}) |
||
31 | * @Groups({"list", "view"}) |
||
32 | */ |
||
33 | private $profile; |
||
34 | |||
35 | /** |
||
36 | * @Groups({"ROLE_ADMIN", "ROLE_MODER"}) |
||
37 | * @ORM\Column(type="string", length=255, unique=true) |
||
38 | */ |
||
39 | private $email; |
||
40 | |||
41 | /** |
||
42 | * @Groups({"ROLE_ADMIN", "ROLE_MODER"}) |
||
43 | * @ORM\Column(type="integer", length=1, options={"default": 0}) |
||
44 | */ |
||
45 | private $isEmailConfirmed = 0; |
||
46 | |||
47 | /** |
||
48 | * @ORM\Column(type="string", length=255, unique=true) |
||
49 | * @Groups({"list", "view"}) |
||
50 | */ |
||
51 | private $username; |
||
52 | |||
53 | /** |
||
54 | * @Groups({"ROLE_ADMIN", "ROLE_MODER"}) |
||
55 | * @ORM\Embedded(class="App\Users\Entity\UserRoles", columnPrefix=false) |
||
56 | */ |
||
57 | private $roles; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | private $plainPassword; |
||
63 | |||
64 | /** |
||
65 | * @ORM\Column(type="string", length=64) |
||
66 | */ |
||
67 | private $password; |
||
68 | |||
69 | 31 | public function __construct(string $email, string $username, string $password) |
|
78 | |||
79 | 12 | public function getProfile(): UserProfile |
|
83 | |||
84 | 8 | public function getId(): ?int |
|
88 | |||
89 | 2 | public function getEmail(): string |
|
93 | |||
94 | public function isEmailConfirmed(): bool |
||
98 | |||
99 | 31 | public function setPlainPassword(string $plainPassword): self |
|
109 | |||
110 | 8 | public function getPlainPassword(): string |
|
114 | |||
115 | 10 | public function setPassword($password, UserPasswordEncoderInterface $passwordEncoder): self |
|
122 | |||
123 | /** |
||
124 | * @param $password |
||
125 | * @param UserPasswordEncoderInterface $passwordEncoder |
||
126 | * @return bool |
||
127 | */ |
||
128 | 6 | public function isPasswordValid($password, UserPasswordEncoderInterface $passwordEncoder): bool |
|
132 | |||
133 | 4 | public function getPassword(): ?string |
|
137 | |||
138 | 11 | public function getSalt(): ?string |
|
142 | |||
143 | 9 | public function getUsername(): ?string |
|
147 | |||
148 | 14 | public function eraseCredentials(): self |
|
154 | |||
155 | 1 | public function confirmEmail(): self |
|
161 | |||
162 | public function changeEmail($email): self |
||
169 | |||
170 | /** |
||
171 | * @return array |
||
172 | */ |
||
173 | 10 | public function getRoles() |
|
177 | |||
178 | 13 | public function getRolesObject(): UserRoles |
|
182 | } |