1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\CommentRepository") |
10
|
|
|
*/ |
11
|
|
|
class Comment extends AppEntity |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @ORM\Id() |
15
|
|
|
* @ORM\GeneratedValue() |
16
|
|
|
* @ORM\Column(type="integer") |
17
|
|
|
*/ |
18
|
|
|
private $id; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @ORM\Column(type="text") |
22
|
|
|
*/ |
23
|
|
|
private $comment; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @ORM\Column(type="datetime") |
27
|
|
|
* @Gedmo\Timestampable(on="create") |
28
|
|
|
*/ |
29
|
|
|
private $createdAt; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Trick", inversedBy="comments") |
33
|
|
|
*/ |
34
|
|
|
private $trick; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="Comments") |
38
|
|
|
*/ |
39
|
|
|
private $user; |
40
|
|
|
|
41
|
|
|
public function getId(): ?int |
42
|
|
|
{ |
43
|
|
|
return $this->id; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getComment(): ?string |
47
|
|
|
{ |
48
|
|
|
return $this->comment; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function setComment(string $comment): self |
52
|
|
|
{ |
53
|
|
|
$this->comment = $comment; |
54
|
|
|
|
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getCreatedAt(): ?\DateTimeInterface |
59
|
|
|
{ |
60
|
|
|
return $this->createdAt; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setCreatedAt(\DateTimeInterface $createdAt): self |
64
|
|
|
{ |
65
|
|
|
$this->createdAt = $createdAt; |
66
|
|
|
|
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getTrick(): ?Trick |
71
|
|
|
{ |
72
|
|
|
return $this->trick; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setTrick(?Trick $trick): self |
76
|
|
|
{ |
77
|
|
|
$this->trick = $trick; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getUser(): ?User |
83
|
|
|
{ |
84
|
|
|
return $this->user; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function setUser(?User $user): self |
88
|
|
|
{ |
89
|
|
|
$this->user = $user; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getCommentExcerpt(){ |
95
|
|
|
return implode(' ', array_slice(explode(' ', $this->getComment()), 0, 10))." ..."; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function __toString() |
99
|
|
|
{ |
100
|
|
|
return $this->getCommentExcerpt(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|