|
1 | 1 | <?php |
| 2 | + |
2 | 3 | declare(strict_types=1); |
3 | 4 |
|
4 | 5 | namespace PhpList\Core\Domain\Model\Identity; |
5 | 6 |
|
6 | | -use Doctrine\ORM\Mapping; |
7 | | -use Doctrine\ORM\Mapping\Column; |
| 7 | +use DateTime; |
| 8 | +use Doctrine\ORM\Mapping as ORM; |
8 | 9 | use PhpList\Core\Domain\Model\Interfaces\CreationDate; |
9 | 10 | use PhpList\Core\Domain\Model\Interfaces\DomainModel; |
10 | 11 | use PhpList\Core\Domain\Model\Interfaces\Identity; |
|
16 | 17 | /** |
17 | 18 | * This class represents an administrator who can log to the system, is allowed to administer |
18 | 19 | * selected lists (as the owner), send campaigns to these lists and edit subscribers. |
19 | | - * |
20 | | - * @Mapping\Entity(repositoryClass="PhpList\Core\Domain\Repository\Identity\AdministratorRepository") |
21 | | - * @Mapping\Table(name="phplist_admin") |
22 | | - * @Mapping\HasLifecycleCallbacks |
23 | | - * |
24 | | - * @author Oliver Klee <[email protected]> |
25 | 20 | */ |
| 21 | +#[ORM\Entity(repositoryClass: "PhpList\Core\Domain\Repository\Identity\AdministratorRepository")] |
| 22 | +#[ORM\Table(name: "phplist_admin")] |
| 23 | +#[ORM\HasLifecycleCallbacks] |
26 | 24 | class Administrator implements DomainModel, Identity, CreationDate, ModificationDate |
27 | 25 | { |
28 | 26 | use IdentityTrait; |
29 | 27 | use CreationDateTrait; |
30 | 28 | use ModificationDateTrait; |
31 | 29 |
|
32 | | - /** |
33 | | - * @var string |
34 | | - * @Column(name="loginname") |
35 | | - */ |
36 | | - private $loginName = ''; |
| 30 | + #[ORM\Column(name: "loginname")] |
| 31 | + private string $loginName = ''; |
37 | 32 |
|
38 | | - /** |
39 | | - * @var string |
40 | | - * @Column(name="email") |
41 | | - */ |
42 | | - private $emailAddress = ''; |
| 33 | + #[ORM\Column(name: "email")] |
| 34 | + private string $emailAddress = ''; |
43 | 35 |
|
44 | | - /** |
45 | | - * @var \DateTime|null |
46 | | - * @Column(type="datetime", name="created") |
47 | | - */ |
48 | | - protected $creationDate = null; |
| 36 | + #[ORM\Column(name: "created", type: "datetime")] |
| 37 | + protected ?DateTime $creationDate = null; |
49 | 38 |
|
50 | | - /** |
51 | | - * @var \DateTime|null |
52 | | - * @Column(type="datetime", name="modified") |
53 | | - */ |
54 | | - protected $modificationDate = null; |
| 39 | + #[ORM\Column(name: "modified", type: "datetime")] |
| 40 | + protected ?DateTime $modificationDate = null; |
55 | 41 |
|
56 | | - /** |
57 | | - * @var string |
58 | | - * @Column(name="password") |
59 | | - */ |
60 | | - private $passwordHash = ''; |
| 42 | + #[ORM\Column(name: "password")] |
| 43 | + private string $passwordHash = ''; |
61 | 44 |
|
62 | | - /** |
63 | | - * @var \DateTime|null |
64 | | - * @Column(type="date", nullable=true, name="passwordchanged") |
65 | | - */ |
66 | | - private $passwordChangeDate = null; |
| 45 | + #[ORM\Column(name: "passwordchanged", type: "date", nullable: true)] |
| 46 | + private ?DateTime $passwordChangeDate = null; |
67 | 47 |
|
68 | | - /** |
69 | | - * @var bool |
70 | | - * @Column(type="boolean") |
71 | | - */ |
72 | | - private $disabled = false; |
| 48 | + #[ORM\Column(type: "boolean")] |
| 49 | + private bool $disabled = false; |
73 | 50 |
|
74 | | - /** |
75 | | - * @var bool |
76 | | - * @Column(type="boolean", name="superuser") |
77 | | - */ |
78 | | - private $superUser = false; |
| 51 | + #[ORM\Column(name: "superuser", type: "boolean")] |
| 52 | + private bool $superUser = false; |
79 | 53 |
|
80 | | - /** |
81 | | - * @return string |
82 | | - */ |
83 | 54 | public function getLoginName(): string |
84 | 55 | { |
85 | 56 | return $this->loginName; |
86 | 57 | } |
87 | 58 |
|
88 | | - /** |
89 | | - * @param string $loginName |
90 | | - * |
91 | | - * @return void |
92 | | - */ |
93 | | - public function setLoginName(string $loginName) |
| 59 | + public function setLoginName(string $loginName): void |
94 | 60 | { |
95 | 61 | $this->loginName = $loginName; |
96 | 62 | } |
97 | 63 |
|
98 | | - /** |
99 | | - * @return string |
100 | | - */ |
101 | 64 | public function getEmailAddress(): string |
102 | 65 | { |
103 | 66 | return $this->emailAddress; |
104 | 67 | } |
105 | 68 |
|
106 | | - /** |
107 | | - * @param string $emailAddress |
108 | | - * |
109 | | - * @return void |
110 | | - */ |
111 | | - public function setEmailAddress(string $emailAddress) |
| 69 | + public function setEmailAddress(string $emailAddress): void |
112 | 70 | { |
113 | 71 | $this->emailAddress = $emailAddress; |
114 | 72 | } |
115 | 73 |
|
116 | | - /** |
117 | | - * @return string |
118 | | - */ |
119 | 74 | public function getPasswordHash(): string |
120 | 75 | { |
121 | 76 | return $this->passwordHash; |
122 | 77 | } |
123 | 78 |
|
124 | 79 | /** |
125 | 80 | * Sets the password hash and updates the password change date to now. |
126 | | - * |
127 | | - * @param string $passwordHash |
128 | | - * |
129 | | - * @return void |
130 | 81 | */ |
131 | | - public function setPasswordHash(string $passwordHash) |
| 82 | + public function setPasswordHash(string $passwordHash): void |
132 | 83 | { |
133 | 84 | $this->passwordHash = $passwordHash; |
134 | | - $this->setPasswordChangeDate(new \DateTime()); |
| 85 | + $this->setPasswordChangeDate(new DateTime()); |
135 | 86 | } |
136 | 87 |
|
137 | | - /** |
138 | | - * @return \DateTime|null |
139 | | - */ |
140 | | - public function getPasswordChangeDate() |
| 88 | + public function getPasswordChangeDate(): ?DateTime |
141 | 89 | { |
142 | 90 | return $this->passwordChangeDate; |
143 | 91 | } |
144 | 92 |
|
145 | | - /** |
146 | | - * @param \DateTime $changeDate |
147 | | - * |
148 | | - * @return void |
149 | | - */ |
150 | | - private function setPasswordChangeDate(\DateTime $changeDate) |
| 93 | + private function setPasswordChangeDate(DateTime $changeDate): void |
151 | 94 | { |
152 | 95 | $this->passwordChangeDate = $changeDate; |
153 | 96 | } |
154 | 97 |
|
155 | | - /** |
156 | | - * @return bool |
157 | | - */ |
158 | 98 | public function isDisabled(): bool |
159 | 99 | { |
160 | 100 | return $this->disabled; |
161 | 101 | } |
162 | 102 |
|
163 | | - /** |
164 | | - * @param bool $disabled |
165 | | - * |
166 | | - * @return void |
167 | | - */ |
168 | | - public function setDisabled(bool $disabled) |
| 103 | + public function setDisabled(bool $disabled): void |
169 | 104 | { |
170 | 105 | $this->disabled = $disabled; |
171 | 106 | } |
172 | 107 |
|
173 | | - /** |
174 | | - * @return bool |
175 | | - */ |
176 | 108 | public function isSuperUser(): bool |
177 | 109 | { |
178 | 110 | return $this->superUser; |
179 | 111 | } |
180 | 112 |
|
181 | | - /** |
182 | | - * @param bool $superUser |
183 | | - * |
184 | | - * @return void |
185 | | - */ |
186 | | - public function setSuperUser(bool $superUser) |
| 113 | + public function setSuperUser(bool $superUser): void |
187 | 114 | { |
188 | 115 | $this->superUser = $superUser; |
189 | 116 | } |
|
0 commit comments