|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\AccountRecoveryBundle\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
14
|
|
|
use libphonenumber\PhoneNumber; |
|
15
|
|
|
use LoginCidadao\CoreBundle\Model\PersonInterface; |
|
16
|
|
|
use LoginCidadao\ValidationBundle\Validator\Constraints as LCAssert; |
|
17
|
|
|
use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber as AssertPhoneNumber; |
|
18
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* AccountRecoveryData |
|
22
|
|
|
* |
|
23
|
|
|
* @ORM\Table(name="account_recovery_data") |
|
24
|
|
|
* @ORM\Entity(repositoryClass="LoginCidadao\AccountRecoveryBundle\Entity\AccountRecoveryDataRepository") |
|
25
|
|
|
* @ORM\HasLifecycleCallbacks |
|
26
|
|
|
*/ |
|
27
|
|
|
class AccountRecoveryData |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var integer |
|
31
|
|
|
* |
|
32
|
|
|
* @ORM\Column(name="id", type="integer") |
|
33
|
|
|
* @ORM\Id |
|
34
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
35
|
|
|
*/ |
|
36
|
|
|
private $id; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var PersonInterface |
|
40
|
|
|
* |
|
41
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Person") |
|
42
|
|
|
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) |
|
43
|
|
|
*/ |
|
44
|
|
|
private $person; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var string |
|
48
|
|
|
* |
|
49
|
|
|
* @ORM\Column(name="email", type="string", length=255, nullable=true) |
|
50
|
|
|
* @LCAssert\Email(strict=true) |
|
51
|
|
|
* @Assert\NotBlank(message="person.validation.email.not_blank") |
|
52
|
|
|
* @Assert\Expression("value != this.getPerson().getEmail()") |
|
53
|
|
|
*/ |
|
54
|
|
|
private $email; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var PhoneNumber |
|
58
|
|
|
* |
|
59
|
|
|
* @ORM\Column(name="mobile", type="phone_number", nullable=true) |
|
60
|
|
|
* @LCAssert\E164PhoneNumber( |
|
61
|
|
|
* maxMessage="person.validation.mobile.length.max", |
|
62
|
|
|
* groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"} |
|
63
|
|
|
* ) |
|
64
|
|
|
* @LCAssert\MobilePhoneNumber( |
|
65
|
|
|
* missing9thDigit="person.validation.mobile.9thDigit", |
|
66
|
|
|
* groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"} |
|
67
|
|
|
* ) |
|
68
|
|
|
* @AssertPhoneNumber( |
|
69
|
|
|
* type="mobile", |
|
70
|
|
|
* groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"} |
|
71
|
|
|
* ) |
|
72
|
|
|
* @Assert\Expression("value != this.getPerson().getMobile()") |
|
73
|
|
|
*/ |
|
74
|
|
|
private $mobile; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @var \DateTime |
|
78
|
|
|
* |
|
79
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
|
80
|
|
|
*/ |
|
81
|
|
|
private $createdAt; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @var \DateTime |
|
85
|
|
|
* |
|
86
|
|
|
* @ORM\Column(name="updated_at", type="datetime") |
|
87
|
|
|
*/ |
|
88
|
|
|
private $updatedAt; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Get id |
|
92
|
|
|
* |
|
93
|
|
|
* @return integer |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getId() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->id; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Set person |
|
102
|
|
|
* |
|
103
|
|
|
* @param PersonInterface $person |
|
104
|
|
|
* |
|
105
|
|
|
* @return AccountRecoveryData |
|
106
|
|
|
*/ |
|
107
|
|
|
public function setPerson(PersonInterface $person): AccountRecoveryData |
|
108
|
|
|
{ |
|
109
|
|
|
$this->person = $person; |
|
110
|
|
|
|
|
111
|
|
|
return $this; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Get person |
|
116
|
|
|
* |
|
117
|
|
|
* @return PersonInterface |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getPerson(): PersonInterface |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->person; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Set email |
|
126
|
|
|
* |
|
127
|
|
|
* @param string $email |
|
128
|
|
|
* |
|
129
|
|
|
* @return AccountRecoveryData |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setEmail(string $email = null): AccountRecoveryData |
|
132
|
|
|
{ |
|
133
|
|
|
$this->email = $email; |
|
134
|
|
|
|
|
135
|
|
|
return $this; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Get email |
|
140
|
|
|
* |
|
141
|
|
|
* @return string |
|
142
|
|
|
*/ |
|
143
|
|
|
public function getEmail(): ?string |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->email; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* Set mobile |
|
150
|
|
|
* |
|
151
|
|
|
* @param PhoneNumber $mobile |
|
152
|
|
|
* |
|
153
|
|
|
* @return AccountRecoveryData |
|
154
|
|
|
*/ |
|
155
|
|
|
public function setMobile(PhoneNumber $mobile = null): AccountRecoveryData |
|
156
|
|
|
{ |
|
157
|
|
|
$this->mobile = $mobile; |
|
158
|
|
|
|
|
159
|
|
|
return $this; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Get mobile |
|
164
|
|
|
* |
|
165
|
|
|
* @return PhoneNumber |
|
166
|
|
|
*/ |
|
167
|
|
|
public function getMobile(): ?PhoneNumber |
|
168
|
|
|
{ |
|
169
|
|
|
return $this->mobile; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Get createdAt |
|
174
|
|
|
* |
|
175
|
|
|
* @return \DateTime |
|
176
|
|
|
*/ |
|
177
|
|
|
public function getCreatedAt() |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->createdAt; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* Get updatedAt |
|
184
|
|
|
* |
|
185
|
|
|
* @return \DateTime |
|
186
|
|
|
*/ |
|
187
|
|
|
public function getUpdatedAt() |
|
188
|
|
|
{ |
|
189
|
|
|
return $this->updatedAt; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @ORM\PrePersist |
|
194
|
|
|
*/ |
|
195
|
|
|
public function setCreatedAt(): AccountRecoveryData |
|
196
|
|
|
{ |
|
197
|
|
|
if (!$this->getCreatedAt() instanceof \DateTime) { |
|
|
|
|
|
|
198
|
|
|
$this->createdAt = new \DateTime(); |
|
199
|
|
|
} |
|
200
|
|
|
if (!$this->updatedAt instanceof \DateTime) { |
|
|
|
|
|
|
201
|
|
|
$this->updatedAt = new \DateTime(); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
return $this; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @ORM\PreUpdate |
|
209
|
|
|
*/ |
|
210
|
|
|
public function setUpdatedAt(): AccountRecoveryData |
|
211
|
|
|
{ |
|
212
|
|
|
$this->updatedAt = new \DateTime('now'); |
|
213
|
|
|
|
|
214
|
|
|
return $this; |
|
215
|
|
|
} |
|
216
|
|
|
} |
|
217
|
|
|
|