1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Article |
12
|
|
|
* |
13
|
|
|
* @ORM\Table(name="article") |
14
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\ArticleRepository") |
15
|
|
|
*/ |
16
|
|
|
class Article |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var int |
20
|
|
|
* |
21
|
|
|
* @ORM\Column(name="id", type="integer") |
22
|
|
|
* @ORM\Id |
23
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
24
|
|
|
*/ |
25
|
|
|
private $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(name="title", type="string", length=100) |
31
|
|
|
* |
32
|
|
|
* @Assert\NotBlank() |
33
|
|
|
* @Assert\Length(max = 100) |
34
|
|
|
*/ |
35
|
|
|
private $title; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
* |
40
|
|
|
* @Gedmo\Slug(fields={"title"}, updatable=true, separator="_") |
41
|
|
|
* @ORM\Column(name="slug", type="string", length=100) |
42
|
|
|
* |
43
|
|
|
* @Assert\NotBlank() |
44
|
|
|
* @Assert\Length(max = 100) |
45
|
|
|
*/ |
46
|
|
|
private $slug; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="articles") |
50
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") |
51
|
|
|
* |
52
|
|
|
* @Assert\NotBlank() |
53
|
|
|
*/ |
54
|
|
|
private $user; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
* |
59
|
|
|
* @ORM\Column(name="picture_small", type="string", length=150, nullable=true) |
60
|
|
|
* |
61
|
|
|
* @Assert\Length(max = 150) |
62
|
|
|
*/ |
63
|
|
|
private $pictureSmall; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var string |
67
|
|
|
* |
68
|
|
|
* @ORM\Column(name="picture_medium", type="string", length=150, nullable=true) |
69
|
|
|
* |
70
|
|
|
* @Assert\Length(max = 150) |
71
|
|
|
*/ |
72
|
|
|
private $pictureMedium; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var string |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(name="picture_big", type="string", length=150, nullable=true) |
78
|
|
|
* |
79
|
|
|
* @Assert\Length(max = 150) |
80
|
|
|
*/ |
81
|
|
|
private $pictureBig; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var string |
85
|
|
|
* |
86
|
|
|
* @ORM\Column(name="text", type="text") |
87
|
|
|
* |
88
|
|
|
* @Assert\Length(max = 10000) |
89
|
|
|
*/ |
90
|
|
|
private $text; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @ORM\ManyToMany(targetEntity="Tag", inversedBy="articles") |
94
|
|
|
* @ORM\JoinTable(name="articles_tags") |
95
|
|
|
*/ |
96
|
|
|
private $tags; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @ORM\ManyToMany(targetEntity="Category", inversedBy="articles") |
100
|
|
|
* @ORM\JoinTable(name="articles_categories") |
101
|
|
|
*/ |
102
|
|
|
private $categories; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @ORM\OneToMany(targetEntity="Comment", mappedBy="article") |
106
|
|
|
*/ |
107
|
|
|
private $comments; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @var \DateTime |
111
|
|
|
* |
112
|
|
|
* @Gedmo\Timestampable(on="create") |
113
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
114
|
|
|
* |
115
|
|
|
* @Assert\DateTime() |
116
|
|
|
*/ |
117
|
|
|
private $createdAt; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @var \DateTime |
121
|
|
|
* |
122
|
|
|
* @Gedmo\Timestampable(on="change", field={"title", "text"}) |
123
|
|
|
* @ORM\Column(name="updated_at", type="datetime", nullable=true) |
124
|
|
|
* |
125
|
|
|
* @Assert\DateTime() |
126
|
|
|
*/ |
127
|
|
|
private $updatedAt; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @var \DateTime |
131
|
|
|
* |
132
|
|
|
* @ORM\Column(name="deleted_at", type="datetime", nullable=true) |
133
|
|
|
* |
134
|
|
|
* @Assert\DateTime() |
135
|
|
|
*/ |
136
|
|
|
private $deletedAt; |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Constructor |
141
|
|
|
*/ |
142
|
|
|
public function __construct() |
143
|
|
|
{ |
144
|
|
|
$this->tags = new ArrayCollection(); |
145
|
|
|
$this->categories = new ArrayCollection(); |
146
|
|
|
$this->comments = new ArrayCollection(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Get id |
151
|
|
|
* |
152
|
|
|
* @return int |
153
|
|
|
*/ |
154
|
|
|
public function getId() |
155
|
|
|
{ |
156
|
|
|
return $this->id; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Set title |
161
|
|
|
* |
162
|
|
|
* @param string $title |
163
|
|
|
* |
164
|
|
|
* @return Article |
165
|
|
|
*/ |
166
|
|
|
public function setTitle($title) |
167
|
|
|
{ |
168
|
|
|
$this->title = $title; |
169
|
|
|
|
170
|
|
|
return $this; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Get title |
175
|
|
|
* |
176
|
|
|
* @return string |
177
|
|
|
*/ |
178
|
5 |
|
public function getTitle() |
179
|
|
|
{ |
180
|
5 |
|
return $this->title; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Set slug |
185
|
|
|
* |
186
|
|
|
* @param string $slug |
187
|
|
|
* |
188
|
|
|
* @return Article |
189
|
|
|
*/ |
190
|
|
|
public function setSlug($slug) |
191
|
|
|
{ |
192
|
|
|
$this->slug = $slug; |
193
|
|
|
|
194
|
|
|
return $this; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Get slug |
199
|
|
|
* |
200
|
|
|
* @return string |
201
|
|
|
*/ |
202
|
5 |
|
public function getSlug() |
203
|
|
|
{ |
204
|
5 |
|
return $this->slug; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Set user |
209
|
|
|
* |
210
|
|
|
* @param string $user |
211
|
|
|
* |
212
|
|
|
* @return Article |
213
|
|
|
*/ |
214
|
|
|
public function setUser($user) |
215
|
|
|
{ |
216
|
|
|
$this->user = $user; |
217
|
|
|
|
218
|
|
|
return $this; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Get user |
223
|
|
|
* |
224
|
|
|
* @return string |
225
|
|
|
*/ |
226
|
6 |
|
public function getUser() |
227
|
|
|
{ |
228
|
6 |
|
return $this->user; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Set text |
233
|
|
|
* |
234
|
|
|
* @param string $text |
235
|
|
|
* |
236
|
|
|
* @return Article |
237
|
|
|
*/ |
238
|
|
|
public function setText($text) |
239
|
|
|
{ |
240
|
|
|
$this->text = $text; |
241
|
|
|
|
242
|
|
|
return $this; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Get text |
247
|
|
|
* |
248
|
|
|
* @return string |
249
|
|
|
*/ |
250
|
5 |
|
public function getText() |
251
|
|
|
{ |
252
|
5 |
|
return $this->text; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Set createdAt |
257
|
|
|
* |
258
|
|
|
* @param \DateTime $createdAt |
259
|
|
|
* |
260
|
|
|
* @return Article |
261
|
|
|
*/ |
262
|
|
|
public function setCreatedAt($createdAt) |
263
|
|
|
{ |
264
|
|
|
$this->createdAt = $createdAt; |
265
|
|
|
|
266
|
|
|
return $this; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* Get createdAt |
271
|
|
|
* |
272
|
|
|
* @return \DateTime |
273
|
|
|
*/ |
274
|
5 |
|
public function getCreatedAt() |
275
|
|
|
{ |
276
|
5 |
|
return $this->createdAt; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* Set updatedAt |
281
|
|
|
* |
282
|
|
|
* @param \DateTime $updatedAt |
283
|
|
|
* |
284
|
|
|
* @return Article |
285
|
|
|
*/ |
286
|
|
|
public function setUpdatedAt($updatedAt) |
287
|
|
|
{ |
288
|
|
|
$this->updatedAt = $updatedAt; |
289
|
|
|
|
290
|
|
|
return $this; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* Get updatedAt |
295
|
|
|
* |
296
|
|
|
* @return \DateTime |
297
|
|
|
*/ |
298
|
|
|
public function getUpdatedAt() |
299
|
|
|
{ |
300
|
|
|
return $this->updatedAt; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Set deletedAt |
305
|
|
|
* |
306
|
|
|
* @param \DateTime $deletedAt |
307
|
|
|
* |
308
|
|
|
* @return Article |
309
|
|
|
*/ |
310
|
|
|
public function setDeletedAt($deletedAt) |
311
|
|
|
{ |
312
|
|
|
$this->deletedAt = $deletedAt; |
313
|
|
|
|
314
|
|
|
return $this; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* Get deletedAt |
319
|
|
|
* |
320
|
|
|
* @return \DateTime |
321
|
|
|
*/ |
322
|
|
|
public function getDeletedAt() |
323
|
|
|
{ |
324
|
|
|
return $this->deletedAt; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Add tag |
329
|
|
|
* |
330
|
|
|
* @param \AppBundle\Entity\Tag $tag |
331
|
|
|
* |
332
|
|
|
* @return Article |
333
|
|
|
*/ |
334
|
|
|
public function addTag(Tag $tag) |
335
|
|
|
{ |
336
|
|
|
$this->tags[] = $tag; |
337
|
|
|
|
338
|
|
|
return $this; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* Remove tag |
343
|
|
|
* |
344
|
|
|
* @param \AppBundle\Entity\Tag $tag |
345
|
|
|
*/ |
346
|
|
|
public function removeTag(Tag $tag) |
347
|
|
|
{ |
348
|
|
|
$this->tags->removeElement($tag); |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* Get tags |
353
|
|
|
* |
354
|
|
|
* @return \Doctrine\Common\Collections\Collection |
355
|
|
|
*/ |
356
|
5 |
|
public function getTags() |
357
|
|
|
{ |
358
|
5 |
|
return $this->tags; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* Add category |
363
|
|
|
* |
364
|
|
|
* @param \AppBundle\Entity\Category $category |
365
|
|
|
* |
366
|
|
|
* @return Article |
367
|
|
|
*/ |
368
|
|
|
public function addCategory(Category $category) |
369
|
|
|
{ |
370
|
|
|
$this->categories[] = $category; |
371
|
|
|
|
372
|
|
|
return $this; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* Remove category |
377
|
|
|
* |
378
|
|
|
* @param \AppBundle\Entity\Category $category |
379
|
|
|
*/ |
380
|
|
|
public function removeCategory(Category $category) |
381
|
|
|
{ |
382
|
|
|
$this->categories->removeElement($category); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* Get categories |
387
|
|
|
* |
388
|
|
|
* @return \Doctrine\Common\Collections\Collection |
389
|
|
|
*/ |
390
|
5 |
|
public function getCategories() |
391
|
|
|
{ |
392
|
5 |
|
return $this->categories; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Add comment |
397
|
|
|
* |
398
|
|
|
* @param \AppBundle\Entity\Comment $comment |
399
|
|
|
* |
400
|
|
|
* @return Article |
401
|
|
|
*/ |
402
|
|
|
public function addComment(Comment $comment) |
403
|
|
|
{ |
404
|
|
|
$this->comments[] = $comment; |
405
|
|
|
|
406
|
|
|
return $this; |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* Remove comment |
411
|
|
|
* |
412
|
|
|
* @param \AppBundle\Entity\Comment $comment |
413
|
|
|
*/ |
414
|
|
|
public function removeComment(Comment $comment) |
415
|
|
|
{ |
416
|
|
|
$this->comments->removeElement($comment); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Get comments |
421
|
|
|
* |
422
|
|
|
* @return \Doctrine\Common\Collections\Collection |
423
|
|
|
*/ |
424
|
|
|
public function getComments() |
425
|
|
|
{ |
426
|
|
|
return $this->comments; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Set pictureSmall |
431
|
|
|
* |
432
|
|
|
* @param string $pictureSmall |
433
|
|
|
* |
434
|
|
|
* @return Article |
435
|
|
|
*/ |
436
|
|
|
public function setPictureSmall($pictureSmall) |
437
|
|
|
{ |
438
|
|
|
$this->pictureSmall = $pictureSmall; |
439
|
|
|
|
440
|
|
|
return $this; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* Get pictureSmall |
445
|
|
|
* |
446
|
|
|
* @return string |
447
|
|
|
*/ |
448
|
|
|
public function getPictureSmall() |
449
|
|
|
{ |
450
|
|
|
return $this->pictureSmall; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Set pictureMedium |
455
|
|
|
* |
456
|
|
|
* @param string $pictureMedium |
457
|
|
|
* |
458
|
|
|
* @return Article |
459
|
|
|
*/ |
460
|
|
|
public function setPictureMedium($pictureMedium) |
461
|
|
|
{ |
462
|
|
|
$this->pictureMedium = $pictureMedium; |
463
|
|
|
|
464
|
|
|
return $this; |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* Get pictureMedium |
469
|
|
|
* |
470
|
|
|
* @return string |
471
|
|
|
*/ |
472
|
4 |
|
public function getPictureMedium() |
473
|
|
|
{ |
474
|
4 |
|
return $this->pictureMedium; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Set pictureBig |
479
|
|
|
* |
480
|
|
|
* @param string $pictureBig |
481
|
|
|
* |
482
|
|
|
* @return Article |
483
|
|
|
*/ |
484
|
|
|
public function setPictureBig($pictureBig) |
485
|
|
|
{ |
486
|
|
|
$this->pictureBig = $pictureBig; |
487
|
|
|
|
488
|
|
|
return $this; |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
/** |
492
|
|
|
* Get pictureBig |
493
|
|
|
* |
494
|
|
|
* @return string |
495
|
|
|
*/ |
496
|
1 |
|
public function getPictureBig() |
497
|
|
|
{ |
498
|
1 |
|
return $this->pictureBig; |
499
|
|
|
} |
500
|
|
|
} |
501
|
|
|
|