1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the CCDNForum ForumBundle |
5
|
|
|
* |
6
|
|
|
* (c) CCDN (c) CodeConsortium <http://www.codeconsortium.com/> |
7
|
|
|
* |
8
|
|
|
* Available on github <http://www.github.com/codeconsortium/> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace CCDNForum\ForumBundle\Entity; |
15
|
|
|
|
16
|
|
|
use CCDNForum\ForumBundle\Entity\Model\Post as AbstractPost; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* |
20
|
|
|
* @category CCDNForum |
21
|
|
|
* @package ForumBundle |
22
|
|
|
* |
23
|
|
|
* @author Reece Fowell <[email protected]> |
24
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
25
|
|
|
* @version Release: 2.0 |
26
|
|
|
* @link https://github.com/codeconsortium/CCDNForumForumBundle |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
class Post extends AbstractPost |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* |
33
|
|
|
* @var integer $id |
34
|
|
|
*/ |
35
|
|
|
protected $id; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* |
39
|
|
|
* @var string $body |
40
|
|
|
*/ |
41
|
|
|
protected $body; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* |
45
|
|
|
* @var \DateTime $createdDate |
46
|
|
|
*/ |
47
|
|
|
protected $createdDate; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
* @var \DateTime $editedDate |
52
|
|
|
*/ |
53
|
|
|
protected $editedDate; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
* @var Boolean $isDeleted |
58
|
|
|
*/ |
59
|
|
|
protected $isDeleted = false; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* |
63
|
|
|
* @var \DateTime $deletedDate |
64
|
|
|
*/ |
65
|
|
|
protected $deletedDate; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* |
69
|
|
|
* @var \DateTime $unlockedDate |
70
|
|
|
*/ |
71
|
|
|
protected $unlockedDate; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* |
75
|
|
|
* @var \DateTime $unlockedUntilDate |
76
|
|
|
*/ |
77
|
|
|
protected $unlockedUntilDate; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* |
81
|
|
|
* @access public |
82
|
|
|
*/ |
83
|
|
|
public function __construct() |
84
|
|
|
{ |
85
|
|
|
parent::__construct(); |
86
|
|
|
// your own logic |
87
|
|
|
|
88
|
|
|
$this->unlockedDate = new \Datetime('now'); |
89
|
|
|
$this->unlockedUntilDate = new \Datetime('now + 7 days'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get id |
94
|
|
|
* |
95
|
|
|
* @return integer |
96
|
|
|
*/ |
97
|
|
|
public function getId() |
98
|
|
|
{ |
99
|
|
|
return $this->id; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Get body |
104
|
|
|
* |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
public function getBody() |
108
|
|
|
{ |
109
|
|
|
return $this->body; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Set body |
114
|
|
|
* |
115
|
|
|
* @param string $body |
116
|
|
|
* @return Post |
117
|
|
|
*/ |
118
|
|
|
public function setBody($body) |
119
|
|
|
{ |
120
|
|
|
$this->body = $body; |
121
|
|
|
|
122
|
|
|
return $this; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Get createdDate |
127
|
|
|
* |
128
|
|
|
* @return \datetime |
129
|
|
|
*/ |
130
|
|
|
public function getCreatedDate() |
131
|
|
|
{ |
132
|
|
|
return $this->createdDate; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Set createdDate |
137
|
|
|
* |
138
|
|
|
* @param \datetime $createdDate |
139
|
|
|
* @return Post |
140
|
|
|
*/ |
141
|
|
|
public function setCreatedDate($createdDate) |
142
|
|
|
{ |
143
|
|
|
$this->createdDate = $createdDate; |
144
|
|
|
|
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Get edited_date |
150
|
|
|
* |
151
|
|
|
* @return \datetime |
152
|
|
|
*/ |
153
|
|
|
public function getEditedDate() |
154
|
|
|
{ |
155
|
|
|
return $this->editedDate; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Set editedDate |
160
|
|
|
* |
161
|
|
|
* @param \datetime $editedDate |
162
|
|
|
* @return Post |
163
|
|
|
*/ |
164
|
|
|
public function setEditedDate($editedDate) |
165
|
|
|
{ |
166
|
|
|
$this->editedDate = $editedDate; |
167
|
|
|
|
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Get isDeleted |
173
|
|
|
* |
174
|
|
|
* @return boolean |
175
|
|
|
*/ |
176
|
|
|
public function isDeleted() |
177
|
|
|
{ |
178
|
|
|
return $this->isDeleted; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Set is_deleted |
183
|
|
|
* |
184
|
|
|
* @param boolean $isDeleted |
185
|
|
|
* @return Post |
186
|
|
|
*/ |
187
|
|
|
public function setDeleted($isDeleted) |
188
|
|
|
{ |
189
|
|
|
$this->isDeleted = $isDeleted; |
190
|
|
|
|
191
|
|
|
return $this; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Get deletedDate |
196
|
|
|
* |
197
|
|
|
* @return \datetime |
198
|
|
|
*/ |
199
|
|
|
public function getDeletedDate() |
200
|
|
|
{ |
201
|
|
|
return $this->deletedDate; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Set deletedDate |
206
|
|
|
* |
207
|
|
|
* @param \datetime $deletedDate |
208
|
|
|
* @return Post |
209
|
|
|
*/ |
210
|
|
|
public function setDeletedDate($deletedDate) |
211
|
|
|
{ |
212
|
|
|
$this->deletedDate = $deletedDate; |
213
|
|
|
|
214
|
|
|
return $this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Get unlockedDate |
219
|
|
|
* |
220
|
|
|
* @return \datetime |
221
|
|
|
*/ |
222
|
|
|
public function getUnlockedDate() |
223
|
|
|
{ |
224
|
|
|
return $this->unlockedDate; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Set unlockedDate |
229
|
|
|
* |
230
|
|
|
* @param \datetime $datetime |
231
|
|
|
* @return Post |
232
|
|
|
*/ |
233
|
|
|
public function setUnlockedDate(\Datetime $datetime) |
234
|
|
|
{ |
235
|
|
|
$this->unlockedDate = $datetime; |
236
|
|
|
|
237
|
|
|
return $this; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* Get unlockedUntilDate |
242
|
|
|
* |
243
|
|
|
* @return \datetime |
244
|
|
|
*/ |
245
|
|
|
public function getUnlockedUntilDate() |
246
|
|
|
{ |
247
|
|
|
return $this->unlockedUntilDate; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Set unlockedUntilDate |
252
|
|
|
* |
253
|
|
|
* @param \datetime $datetime |
254
|
|
|
* @return Post |
255
|
|
|
*/ |
256
|
|
|
public function setUnlockedUntilDate(\Datetime $datetime) |
257
|
|
|
{ |
258
|
|
|
$this->unlockedUntilDate = $datetime; |
259
|
|
|
|
260
|
|
|
return $this; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Get isUnlocked |
265
|
|
|
* |
266
|
|
|
* @return \datetime |
|
|
|
|
267
|
|
|
*/ |
268
|
|
|
public function isLocked() |
269
|
|
|
{ |
270
|
|
|
return $this->unlockedUntilDate > new \Datetime('now') ? false : true; |
271
|
|
|
} |
272
|
|
|
} |
273
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.