1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
4
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Entities; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @since 2.0 |
12
|
|
|
* |
13
|
|
|
* @ORM\Table( name="subscription" ) |
14
|
|
|
* @ORM\Entity |
15
|
|
|
*/ |
16
|
|
|
class Subscription { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
* |
21
|
|
|
* @ORM\Column(name="full_name", type="string", length=250, options={"default":""}, nullable=false) |
22
|
|
|
*/ |
23
|
|
|
private $fullName = ''; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
* |
28
|
|
|
* @ORM\Column(name="email", type="string", length=250, options={"default":""}, nullable=false) |
29
|
|
|
*/ |
30
|
|
|
private $email = ''; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var \DateTime|null |
34
|
|
|
* |
35
|
|
|
* @ORM\Column(name="export", type="datetime", nullable=true) |
36
|
|
|
*/ |
37
|
|
|
private $export; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var \DateTime|null |
41
|
|
|
* |
42
|
|
|
* @ORM\Column(name="backup", type="datetime", nullable=true) |
43
|
|
|
*/ |
44
|
|
|
private $backup; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var integer |
48
|
|
|
* |
49
|
|
|
* @ORM\Column(name="status", type="smallint", options={"default":0}, nullable=true) |
50
|
|
|
*/ |
51
|
|
|
private $status = 0; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
* |
56
|
|
|
* @ORM\Column(name="confirmationCode", type="string", length=32, nullable=true) |
57
|
|
|
*/ |
58
|
|
|
private $confirmationCode; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var integer |
62
|
|
|
* |
63
|
|
|
* @ORM\Column(name="id", type="integer") |
64
|
|
|
* @ORM\Id |
65
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
66
|
|
|
*/ |
67
|
|
|
private $id; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @ORM\ManyToOne(targetEntity="Address") |
71
|
|
|
* @ORM\JoinColumn(name="address_id", referencedColumnName="id") |
72
|
|
|
*/ |
73
|
|
|
private $address; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @var string |
77
|
|
|
* |
78
|
|
|
* @ORM\Column(name="tracking", type="string", length=50, nullable=true) |
79
|
|
|
*/ |
80
|
|
|
private $tracking; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var string |
84
|
|
|
* |
85
|
|
|
* @ORM\Column(name="source", type="string", length=50, nullable=true) |
86
|
|
|
*/ |
87
|
|
|
private $source; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @var \DateTime |
91
|
|
|
* @Gedmo\Timestampable(on="create") |
92
|
|
|
* @ORM\Column(type="datetime") |
93
|
|
|
*/ |
94
|
|
|
private $createdAt; |
95
|
|
|
|
96
|
|
|
// TODO: replace by private constants once using PHP 7.1+ |
97
|
|
|
private $STATUS_NEW = 0; |
98
|
|
|
private $STATUS_CONFIRMED = 1; |
99
|
|
|
private $STATUS_MODERATION = 2; |
100
|
|
|
|
101
|
|
|
public function setFullName( string $fullName ): self { |
102
|
|
|
$this->fullName = $fullName; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function getFullName(): string { |
108
|
|
|
return $this->fullName; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
public function setEmail( string $email ): self { |
112
|
|
|
$this->email = $email; |
113
|
|
|
|
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getEmail(): string { |
118
|
|
|
return $this->email; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function setExport( \DateTime $export = null ): self { |
122
|
|
|
$this->export = $export; |
123
|
|
|
|
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return \DateTime|null |
129
|
|
|
*/ |
130
|
|
|
public function getExport() { |
131
|
|
|
return $this->export; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function setBackup( \DateTime $backup = null ): self { |
135
|
|
|
$this->backup = $backup; |
136
|
|
|
|
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return \DateTime|null |
142
|
|
|
*/ |
143
|
|
|
public function getBackup() { |
144
|
|
|
return $this->backup; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Usage of this method is discouraged, it's only for initialization with Doctrine. |
149
|
|
|
* |
150
|
|
|
* @see Subscription::markAsConfirmed() |
151
|
|
|
* @see Subscription::markForModeration() |
152
|
|
|
* @param int $status |
153
|
|
|
* @return Subscription |
154
|
|
|
*/ |
155
|
|
|
public function setStatus( int $status ): self { |
156
|
|
|
$this->status = $status; |
157
|
|
|
|
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Usage of this method is discouraged. Try using something like @see isUnconfirmed |
163
|
|
|
* |
164
|
|
|
* @return int |
165
|
|
|
*/ |
166
|
|
|
public function getStatus(): int { |
167
|
|
|
return $this->status; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function setConfirmationCode( string $confirmationCode ): self { |
171
|
|
|
$this->confirmationCode = $confirmationCode; |
172
|
|
|
|
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function getConfirmationCode(): string { |
177
|
|
|
return $this->confirmationCode; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
public function getId(): int { |
181
|
|
|
return $this->id; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function getAddress(): Address { |
185
|
|
|
return $this->address; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function setAddress( Address $address ) { |
189
|
|
|
$this->address = $address; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function getCreatedAt(): \DateTime { |
193
|
|
|
return $this->createdAt; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
public function setCreatedAt( \DateTime $createdAt ): self { |
197
|
|
|
$this->createdAt = $createdAt; |
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
public function getTracking(): string { |
202
|
|
|
return $this->tracking; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
public function setTracking( string $tracking ) { |
206
|
|
|
$this->tracking = $tracking; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @since 3.0 |
211
|
|
|
*/ |
212
|
1 |
|
public function setSource( string $source ): self { |
213
|
1 |
|
$this->source = $source; |
214
|
|
|
|
215
|
1 |
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @since 3.0 |
220
|
|
|
*/ |
221
|
1 |
|
public function getSource(): string { |
222
|
1 |
|
return $this->source; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @since 3.0 |
227
|
|
|
*/ |
228
|
1 |
|
public function markAsConfirmed() { |
229
|
1 |
|
$this->status = $this->STATUS_CONFIRMED; |
230
|
1 |
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* @since 3.0 |
234
|
|
|
*/ |
235
|
2 |
|
public function markForModeration() { |
236
|
2 |
|
$this->status = $this->STATUS_MODERATION; |
237
|
2 |
|
} |
238
|
|
|
|
239
|
3 |
|
public function isUnconfirmed(): bool { |
240
|
3 |
|
return $this->status !== $this->STATUS_CONFIRMED; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @since 3.0 |
245
|
|
|
*/ |
246
|
2 |
|
public function needsModeration(): bool { |
247
|
2 |
|
return $this->status === $this->STATUS_MODERATION; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
} |
251
|
|
|
|