|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Mykees\CommentBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Mykees\CommentBundle\Interfaces\Commentable; |
|
7
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @ORM\MappedSuperclass |
|
11
|
|
|
*/ |
|
12
|
|
|
abstract class Comment implements Commentable |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var string |
|
16
|
|
|
* |
|
17
|
|
|
* @ORM\Column(name="username", type="string", length=100) |
|
18
|
|
|
* @Assert\NotBlank(message="Vous devez entre un Nom") |
|
19
|
|
|
*/ |
|
20
|
|
|
private $username; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
* |
|
25
|
|
|
* @ORM\Column(name="email", type="string", length=255) |
|
26
|
|
|
* @Assert\Email(message="L'Email n'est pas valid") |
|
27
|
|
|
* @Assert\NotBlank(message="Vous devez préciser un Email.") |
|
28
|
|
|
*/ |
|
29
|
|
|
private $email; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
* |
|
34
|
|
|
* @ORM\Column(name="content", type="text") |
|
35
|
|
|
* @Assert\NotBlank(message="Vous devez entrer un Message.") |
|
36
|
|
|
*/ |
|
37
|
|
|
private $content; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var \DateTime |
|
41
|
|
|
* |
|
42
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
|
43
|
|
|
* @Assert\DateTime() |
|
44
|
|
|
*/ |
|
45
|
|
|
private $createdAt; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var string |
|
49
|
|
|
* |
|
50
|
|
|
* @ORM\Column(name="model", type="string", length=60) |
|
51
|
|
|
*/ |
|
52
|
|
|
private $model; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var integer |
|
56
|
|
|
* |
|
57
|
|
|
* @ORM\Column(name="model_id", type="integer") |
|
58
|
|
|
*/ |
|
59
|
|
|
private $modelId; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var integer |
|
63
|
|
|
* |
|
64
|
|
|
* @ORM\Column(name="parent_id", type="integer") |
|
65
|
|
|
*/ |
|
66
|
|
|
private $parentId; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var boolean |
|
70
|
|
|
* |
|
71
|
|
|
* @ORM\Column(name="spam", type="boolean") |
|
72
|
|
|
*/ |
|
73
|
|
|
private $spam; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @var string |
|
77
|
|
|
* |
|
78
|
|
|
* @ORM\Column(name="ip", type="string", length=255) |
|
79
|
|
|
*/ |
|
80
|
|
|
private $ip; |
|
81
|
|
|
|
|
82
|
|
|
private $depth = 0; |
|
83
|
|
|
|
|
84
|
|
|
private $depthReached; |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
private $children = []; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @ORM\PrePersist |
|
91
|
|
|
*/ |
|
92
|
|
|
public function updateDate() |
|
93
|
|
|
{ |
|
94
|
|
|
$this->setCreatedAt(new \DateTime()); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Set username |
|
99
|
|
|
* |
|
100
|
|
|
* @param string $username |
|
101
|
|
|
* @return Comment |
|
102
|
|
|
*/ |
|
103
|
|
|
public function setUsername($username) |
|
104
|
|
|
{ |
|
105
|
|
|
$this->username = $username; |
|
106
|
|
|
|
|
107
|
|
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Get username |
|
112
|
|
|
* |
|
113
|
|
|
* @return string |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getUsername() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->username; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Set email |
|
122
|
|
|
* |
|
123
|
|
|
* @param string $email |
|
124
|
|
|
* @return Comment |
|
125
|
|
|
*/ |
|
126
|
|
|
public function setEmail($email) |
|
127
|
|
|
{ |
|
128
|
|
|
$this->email = $email; |
|
129
|
|
|
|
|
130
|
|
|
return $this; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Get email |
|
135
|
|
|
* |
|
136
|
|
|
* @return string |
|
137
|
|
|
*/ |
|
138
|
|
|
public function getEmail() |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->email; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Set content |
|
145
|
|
|
* |
|
146
|
|
|
* @param string $content |
|
147
|
|
|
* @return Comment |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setContent($content) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->content = $content; |
|
152
|
|
|
|
|
153
|
|
|
return $this; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Get content |
|
158
|
|
|
* |
|
159
|
|
|
* @return string |
|
160
|
|
|
*/ |
|
161
|
|
|
public function getContent() |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->content; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Set createdAt |
|
168
|
|
|
* |
|
169
|
|
|
* @param \DateTime $createdAt |
|
170
|
|
|
* @return Comment |
|
171
|
|
|
*/ |
|
172
|
|
|
public function setCreatedAt($createdAt) |
|
173
|
|
|
{ |
|
174
|
|
|
$this->createdAt = $createdAt; |
|
175
|
|
|
|
|
176
|
|
|
return $this; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* Get createdAt |
|
181
|
|
|
* |
|
182
|
|
|
* @return \DateTime |
|
183
|
|
|
*/ |
|
184
|
|
|
public function getCreatedAt() |
|
185
|
|
|
{ |
|
186
|
|
|
return $this->createdAt; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Set model |
|
191
|
|
|
* |
|
192
|
|
|
* @param string $model |
|
193
|
|
|
* @return Comment |
|
194
|
|
|
*/ |
|
195
|
|
|
public function setModel($model) |
|
196
|
|
|
{ |
|
197
|
|
|
$this->model = $model; |
|
198
|
|
|
|
|
199
|
|
|
return $this; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* Get model |
|
204
|
|
|
* |
|
205
|
|
|
* @return string |
|
206
|
|
|
*/ |
|
207
|
|
|
public function getModel() |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->model; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* Set modelId |
|
214
|
|
|
* |
|
215
|
|
|
* @param integer $modelId |
|
216
|
|
|
* @return Comment |
|
217
|
|
|
*/ |
|
218
|
|
|
public function setModelId($modelId) |
|
219
|
|
|
{ |
|
220
|
|
|
$this->modelId = $modelId; |
|
221
|
|
|
|
|
222
|
|
|
return $this; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* Get modelId |
|
227
|
|
|
* |
|
228
|
|
|
* @return integer |
|
229
|
|
|
*/ |
|
230
|
|
|
public function getModelId() |
|
231
|
|
|
{ |
|
232
|
|
|
return $this->modelId; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* Set parentId |
|
237
|
|
|
* |
|
238
|
|
|
* @param integer $parentId |
|
239
|
|
|
* @return Comment |
|
240
|
|
|
*/ |
|
241
|
|
|
public function setParentId($parentId) |
|
242
|
|
|
{ |
|
243
|
|
|
$this->parentId = $parentId; |
|
244
|
|
|
|
|
245
|
|
|
return $this; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* Get parentId |
|
250
|
|
|
* |
|
251
|
|
|
* @return integer |
|
252
|
|
|
*/ |
|
253
|
|
|
public function getParentId() |
|
254
|
|
|
{ |
|
255
|
|
|
return $this->parentId; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* Set spam |
|
260
|
|
|
* |
|
261
|
|
|
* @param boolean $spam |
|
262
|
|
|
* @return Comment |
|
263
|
|
|
*/ |
|
264
|
|
|
public function setSpam($spam) |
|
265
|
|
|
{ |
|
266
|
|
|
$this->spam = $spam; |
|
267
|
|
|
|
|
268
|
|
|
return $this; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* Get spam |
|
273
|
|
|
* |
|
274
|
|
|
* @return boolean |
|
275
|
|
|
*/ |
|
276
|
|
|
public function getSpam() |
|
277
|
|
|
{ |
|
278
|
|
|
return $this->spam; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* Set ip |
|
283
|
|
|
* |
|
284
|
|
|
* @param string $ip |
|
285
|
|
|
* @return Comment |
|
286
|
|
|
*/ |
|
287
|
|
|
public function setIp($ip) |
|
288
|
|
|
{ |
|
289
|
|
|
$this->ip = $ip; |
|
290
|
|
|
|
|
291
|
|
|
return $this; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
/** |
|
295
|
|
|
* Get ip |
|
296
|
|
|
* |
|
297
|
|
|
* @return string |
|
298
|
|
|
*/ |
|
299
|
|
|
public function getIp() |
|
300
|
|
|
{ |
|
301
|
|
|
return $this->ip; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/** |
|
305
|
|
|
* @return mixed |
|
306
|
|
|
*/ |
|
307
|
|
|
public function getChildren() |
|
308
|
|
|
{ |
|
309
|
|
|
return $this->children; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* @param mixed $children |
|
314
|
|
|
*/ |
|
315
|
|
|
public function setChildren(Comment $children) |
|
316
|
|
|
{ |
|
317
|
|
|
array_unshift($this->children,$children); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* @return int |
|
322
|
|
|
*/ |
|
323
|
|
|
public function getDepth() |
|
324
|
|
|
{ |
|
325
|
|
|
return $this->depth; |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* @param int $depth |
|
330
|
|
|
*/ |
|
331
|
|
|
public function setDepth($depth) |
|
332
|
|
|
{ |
|
333
|
|
|
$this->depth = $depth; |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
/** |
|
337
|
|
|
* @return mixed |
|
338
|
|
|
*/ |
|
339
|
|
|
public function getDepthReached() |
|
340
|
|
|
{ |
|
341
|
|
|
return $this->depthReached; |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
/** |
|
345
|
|
|
* @param mixed $depthReached |
|
346
|
|
|
*/ |
|
347
|
|
|
public function setDepthReached($depthReached) |
|
348
|
|
|
{ |
|
349
|
|
|
$this->depthReached = $depthReached; |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
} |
|
353
|
|
|
|