|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
7
|
|
|
use Skobkin\Bundle\PointToolsBundle\Entity\User; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @ORM\Table(name="comments", schema="posts", indexes={ |
|
11
|
|
|
* @ORM\Index(name="idx_comment_created_at", columns={"created_at"}) |
|
12
|
|
|
* }) |
|
13
|
|
|
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository") |
|
14
|
|
|
*/ |
|
15
|
|
|
class Comment |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var int |
|
19
|
|
|
* |
|
20
|
|
|
* @ORM\Column(name="id", type="integer") |
|
21
|
|
|
* @ORM\Id |
|
22
|
|
|
* @ORM\GeneratedValue |
|
23
|
|
|
*/ |
|
24
|
|
|
private $id; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
* |
|
29
|
|
|
* @ORM\Column(name="text", type="text") |
|
30
|
|
|
*/ |
|
31
|
|
|
private $text; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var \DateTime |
|
35
|
|
|
* |
|
36
|
|
|
* @ORM\Column(name="created_at", type="datetime") |
|
37
|
|
|
*/ |
|
38
|
|
|
private $createdAt; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var boolean |
|
42
|
|
|
* |
|
43
|
|
|
* @ORM\Column(name="is_rec", type="boolean") |
|
44
|
|
|
*/ |
|
45
|
|
|
private $rec; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var bool |
|
49
|
|
|
* |
|
50
|
|
|
* @ORM\Column(name="is_deleted", type="boolean") |
|
51
|
|
|
*/ |
|
52
|
|
|
private $deleted = false; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var Post |
|
56
|
|
|
* |
|
57
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post", inversedBy="comments") |
|
58
|
|
|
* @ORM\JoinColumn(name="post_id") |
|
59
|
|
|
*/ |
|
60
|
|
|
private $post; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @var int |
|
64
|
|
|
* |
|
65
|
|
|
* @ORM\Column(name="number", type="smallint") |
|
66
|
|
|
*/ |
|
67
|
|
|
private $number; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var User |
|
71
|
|
|
* |
|
72
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\User", fetch="EAGER") |
|
73
|
|
|
* @ORM\JoinColumn(name="author_id") |
|
74
|
|
|
*/ |
|
75
|
|
|
private $author; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @var File[]|ArrayCollection |
|
79
|
|
|
* |
|
80
|
|
|
* @ORM\ManyToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\File", fetch="EXTRA_LAZY", cascade={"persist"}) |
|
81
|
|
|
* @ORM\JoinTable(name="comments_files", schema="posts", |
|
82
|
|
|
* joinColumns={@ORM\JoinColumn(name="comment_id")}, |
|
83
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="file_id")} |
|
84
|
|
|
* ) |
|
85
|
|
|
*/ |
|
86
|
|
|
private $files; |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @var Comment|null |
|
90
|
|
|
* |
|
91
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment", inversedBy="children") |
|
92
|
|
|
* @ORM\JoinColumn(name="parent_id", nullable=true) |
|
93
|
|
|
*/ |
|
94
|
|
|
private $parent; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @var Comment[]|ArrayCollection |
|
98
|
|
|
* |
|
99
|
|
|
* @ORM\OneToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment", fetch="EXTRA_LAZY", mappedBy="parent") |
|
100
|
|
|
*/ |
|
101
|
|
|
private $children; |
|
102
|
|
|
|
|
103
|
|
|
|
|
104
|
|
|
public function __construct() |
|
105
|
|
|
{ |
|
106
|
|
|
$this->files = new ArrayCollection(); |
|
107
|
|
|
$this->children = new ArrayCollection(); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function getId(): int |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->id; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function setCreatedAt(\DateTime $createdAt): self |
|
116
|
|
|
{ |
|
117
|
|
|
$this->createdAt = $createdAt; |
|
118
|
|
|
|
|
119
|
|
|
return $this; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function getCreatedAt(): \DateTime |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->createdAt; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function setText(string $text): self |
|
128
|
|
|
{ |
|
129
|
|
|
$this->text = $text; |
|
130
|
|
|
|
|
131
|
|
|
return $this; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getText(): string |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->text; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function setRec(bool $rec): self |
|
140
|
|
|
{ |
|
141
|
|
|
$this->rec = $rec; |
|
142
|
|
|
|
|
143
|
|
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function isRec(): bool |
|
147
|
|
|
{ |
|
148
|
|
|
return $this->rec; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
public function getRec(): bool |
|
152
|
|
|
{ |
|
153
|
|
|
return $this->rec; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
public function getPost(): Post |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->post; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
public function setPost(Post $post): self |
|
162
|
|
|
{ |
|
163
|
|
|
$this->post = $post; |
|
164
|
|
|
|
|
165
|
|
|
return $this; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
public function setNumber(int $number): self |
|
169
|
|
|
{ |
|
170
|
|
|
$this->number = $number; |
|
171
|
|
|
|
|
172
|
|
|
return $this; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
public function getNumber(): int |
|
176
|
|
|
{ |
|
177
|
|
|
return $this->number; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
public function getAuthor(): User |
|
181
|
|
|
{ |
|
182
|
|
|
return $this->author; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
public function setAuthor(User $author): self |
|
186
|
|
|
{ |
|
187
|
|
|
$this->author = $author; |
|
188
|
|
|
|
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
public function addFile(File $files): self |
|
193
|
|
|
{ |
|
194
|
|
|
$this->files[] = $files; |
|
195
|
|
|
|
|
196
|
|
|
return $this; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
public function removeFile(File $files): void |
|
200
|
|
|
{ |
|
201
|
|
|
$this->files->removeElement($files); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* @return File[]|ArrayCollection |
|
206
|
|
|
*/ |
|
207
|
|
|
public function getFiles(): iterable |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->files; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
public function getParent(): ?Comment |
|
213
|
|
|
{ |
|
214
|
|
|
return $this->parent; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
public function setParent(Comment $parent): self |
|
218
|
|
|
{ |
|
219
|
|
|
$this->parent = $parent; |
|
220
|
|
|
|
|
221
|
|
|
return $this; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
public function setDeleted(bool $deleted): self |
|
225
|
|
|
{ |
|
226
|
|
|
$this->deleted = $deleted; |
|
227
|
|
|
|
|
228
|
|
|
return $this; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
public function getDeleted(): bool |
|
232
|
|
|
{ |
|
233
|
|
|
return $this->deleted; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
public function isDeleted(): bool |
|
237
|
|
|
{ |
|
238
|
|
|
return $this->deleted; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
public function addChild(Comment $children): self |
|
242
|
|
|
{ |
|
243
|
|
|
$this->children[] = $children; |
|
244
|
|
|
|
|
245
|
|
|
return $this; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
public function removeChild(Comment $children): void |
|
249
|
|
|
{ |
|
250
|
|
|
$this->children->removeElement($children); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* @return Comment[]|ArrayCollection |
|
255
|
|
|
*/ |
|
256
|
|
|
public function getChildren(): iterable |
|
257
|
|
|
{ |
|
258
|
|
|
return $this->children; |
|
259
|
|
|
} |
|
260
|
|
|
} |
|
261
|
|
|
|