1 | <?php |
||
22 | class User implements UserInterface |
||
23 | { |
||
24 | /** |
||
25 | * @ORM\Id() |
||
26 | * @ORM\GeneratedValue() |
||
27 | * @ORM\Column(type="integer") |
||
28 | * @Expose |
||
29 | */ |
||
30 | private $id; |
||
31 | |||
32 | /** |
||
33 | * @var $profile UserProfile |
||
34 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserProfile", cascade={"persist", "remove"}) |
||
35 | * @Expose |
||
36 | */ |
||
37 | private $profile; |
||
38 | |||
39 | /** |
||
40 | * @ORM\Column(type="string", length=255, unique=true) |
||
41 | */ |
||
42 | private $email; |
||
43 | |||
44 | /** |
||
45 | * @ORM\Column(type="integer", length=1, options={"default": 0}) |
||
46 | */ |
||
47 | private $isEmailConfirmed = 0; |
||
48 | |||
49 | /** |
||
50 | * @ORM\Column(type="string", length=255, unique=true) |
||
51 | * @Expose |
||
52 | */ |
||
53 | private $username; |
||
54 | |||
55 | /** |
||
56 | * @ORM\Embedded(class="App\Users\Entity\UserRoles", columnPrefix=false) |
||
57 | */ |
||
58 | private $roles; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | private $plainPassword; |
||
64 | |||
65 | /** |
||
66 | * @ORM\Column(type="string", length=64) |
||
67 | */ |
||
68 | private $password; |
||
69 | |||
70 | public function __construct(string $email, string $username, string $password) |
||
71 | { |
||
72 | 31 | $this->roles = new UserRoles(); |
|
73 | $this->profile = new UserProfile($this); |
||
74 | 31 | ||
75 | 31 | $this->email = $email; |
|
76 | 31 | $this->username = $username; |
|
77 | $this->setPlainPassword($password); |
||
78 | 8 | } |
|
79 | |||
80 | 8 | public function getProfile(): UserProfile |
|
84 | |||
85 | 4 | public function getId(): ?int |
|
89 | |||
90 | 31 | public function getEmail(): string |
|
91 | 3 | { |
|
92 | 3 | return $this->email; |
|
93 | } |
||
94 | |||
95 | public function setPlainPassword(string $plainPassword): self |
||
105 | 1 | ||
106 | 1 | public function getPlainPassword(): string |
|
107 | { |
||
108 | return (string)$this->plainPassword; |
||
109 | } |
||
110 | |||
111 | public function setPassword($password, UserPasswordEncoderInterface $passwordEncoder): self |
||
118 | |||
119 | 3 | public function isPasswordValid($password, UserPasswordEncoderInterface $passwordEncoder): bool |
|
123 | |||
124 | 35 | public function getPassword(): ?string |
|
125 | { |
||
126 | 35 | return $this->password; |
|
127 | 33 | } |
|
128 | |||
129 | public function getSalt(): ?string |
||
133 | |||
134 | public function getUsername(): ?string |
||
135 | { |
||
136 | 5 | return $this->username; |
|
137 | } |
||
138 | |||
139 | 33 | public function eraseCredentials(): self |
|
145 | |||
146 | 5 | public function confirmEmail(): self |
|
152 | 5 | ||
153 | public function changeEmail($email): self |
||
154 | { |
||
155 | 7 | $this->email = $email; |
|
156 | $this->isEmailConfirmed = 0; |
||
157 | 7 | ||
158 | return $this; |
||
159 | } |
||
160 | 9 | ||
161 | /** |
||
162 | 9 | * @return array |
|
163 | */ |
||
164 | 9 | public function getRoles() |
|
168 | |||
169 | 6 | public function getRolesObject(): UserRoles |
|
173 | } |