|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Doctrine\Common\Collections\Collection; |
|
9
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
10
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
11
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
12
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
13
|
|
|
use Doctrine\ORM\Mapping\Index; |
|
14
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
15
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
16
|
|
|
use Doctrine\ORM\Mapping\OneToMany; |
|
17
|
|
|
use Doctrine\ORM\Mapping\OrderBy; |
|
18
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
19
|
|
|
use Stu\Module\Communication\View\ShowSingleKn\ShowSingleKn; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @Entity(repositoryClass="Stu\Orm\Repository\KnPostRepository") |
|
23
|
|
|
* @Table( |
|
24
|
|
|
* name="stu_kn", |
|
25
|
|
|
* indexes={ |
|
26
|
|
|
* @Index(name="plot_idx", columns={"plot_id"}), |
|
27
|
|
|
* @Index(name="kn_post_date_idx", columns={"date"}), |
|
28
|
|
|
* @Index(name="kn_post_user_idx", columns={"user_id"}) |
|
29
|
|
|
* } |
|
30
|
|
|
* ) |
|
31
|
|
|
**/ |
|
32
|
|
|
class KnPost implements KnPostInterface |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @Id |
|
36
|
|
|
* @Column(type="integer") |
|
37
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
|
38
|
|
|
* |
|
39
|
|
|
*/ |
|
40
|
|
|
private int $id; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @Column(type="string", nullable=true) |
|
44
|
|
|
* |
|
45
|
|
|
*/ |
|
46
|
|
|
private ?string $titel = ''; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @Column(type="text") |
|
50
|
|
|
* |
|
51
|
|
|
*/ |
|
52
|
|
|
private string $text = ''; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @Column(type="integer") |
|
56
|
|
|
* |
|
57
|
|
|
*/ |
|
58
|
|
|
private int $date = 0; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @Column(type="string") |
|
62
|
|
|
* |
|
63
|
|
|
*/ |
|
64
|
|
|
private string $username = ''; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @Column(type="integer", nullable=true) |
|
68
|
|
|
* |
|
69
|
|
|
*/ |
|
70
|
|
|
private ?int $user_id = 0; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @Column(type="integer", nullable=true) |
|
74
|
|
|
* |
|
75
|
|
|
*/ |
|
76
|
|
|
private ?int $del_user_id = 0; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @Column(type="integer") |
|
80
|
|
|
* |
|
81
|
|
|
*/ |
|
82
|
|
|
private int $lastedit = 0; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @Column(type="integer", nullable=true) |
|
86
|
|
|
* |
|
87
|
|
|
*/ |
|
88
|
|
|
private ?int $plot_id = null; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @Column(type="json") |
|
92
|
|
|
* |
|
93
|
|
|
* @var array<mixed> |
|
94
|
|
|
*/ |
|
95
|
|
|
private array $ratings = []; |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @var ArrayCollection<int, KnCommentInterface> |
|
99
|
|
|
* |
|
100
|
|
|
* @OneToMany(targetEntity="KnComment", mappedBy="post") |
|
101
|
|
|
* @OrderBy({"id": "ASC"}) |
|
102
|
|
|
*/ |
|
103
|
|
|
private Collection $comments; |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* |
|
107
|
|
|
* @ManyToOne(targetEntity="RpgPlot", inversedBy="posts") |
|
108
|
|
|
* @JoinColumn(name="plot_id", referencedColumnName="id") |
|
109
|
|
|
*/ |
|
110
|
|
|
private ?RpgPlotInterface $rpgPlot = null; |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* |
|
114
|
|
|
* @ManyToOne(targetEntity="User") |
|
115
|
|
|
* @JoinColumn(name="user_id", referencedColumnName="id") |
|
116
|
|
|
*/ |
|
117
|
|
|
private UserInterface $user; |
|
118
|
|
|
|
|
119
|
|
|
public function __construct() |
|
120
|
|
|
{ |
|
121
|
|
|
$this->comments = new ArrayCollection(); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function getId(): int |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->id; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function getTitle(): ?string |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->titel; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function setTitle(string $title): KnPostInterface |
|
135
|
|
|
{ |
|
136
|
|
|
$this->titel = $title; |
|
137
|
|
|
|
|
138
|
|
|
return $this; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function getText(): string |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->text; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function setText(string $text): KnPostInterface |
|
147
|
|
|
{ |
|
148
|
|
|
$this->text = $text; |
|
149
|
|
|
|
|
150
|
|
|
return $this; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
public function getDate(): int |
|
154
|
|
|
{ |
|
155
|
|
|
return $this->date; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
public function setDate(int $date): KnPostInterface |
|
159
|
|
|
{ |
|
160
|
|
|
$this->date = $date; |
|
161
|
|
|
|
|
162
|
|
|
return $this; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
public function getUsername(): string |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->username; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
public function setUsername(string $username): KnPostInterface |
|
171
|
|
|
{ |
|
172
|
|
|
$this->username = $username; |
|
173
|
|
|
|
|
174
|
|
|
return $this; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function getUserId(): int |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->user_id; |
|
|
|
|
|
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
public function getdelUserId(): ?int |
|
183
|
|
|
{ |
|
184
|
|
|
return $this->del_user_id; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function setdelUserId(?int $userid): KnPostInterface |
|
188
|
|
|
{ |
|
189
|
|
|
$this->del_user_id = $userid; |
|
190
|
|
|
|
|
191
|
|
|
return $this; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
public function getUser(): UserInterface |
|
195
|
|
|
{ |
|
196
|
|
|
return $this->user; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
public function setUser(UserInterface $user): KnPostInterface |
|
200
|
|
|
{ |
|
201
|
|
|
$this->user = $user; |
|
202
|
|
|
return $this; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
public function getEditDate(): int |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->lastedit; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
public function setEditDate(int $editDate): KnPostInterface |
|
211
|
|
|
{ |
|
212
|
|
|
$this->lastedit = $editDate; |
|
213
|
|
|
|
|
214
|
|
|
return $this; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
public function getPlotId(): ?int |
|
218
|
|
|
{ |
|
219
|
|
|
return $this->plot_id; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
public function getRpgPlot(): ?RpgPlotInterface |
|
223
|
|
|
{ |
|
224
|
|
|
return $this->rpgPlot; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
public function setRpgPlot(?RpgPlotInterface $rpgPlot): KnPostInterface |
|
228
|
|
|
{ |
|
229
|
|
|
$this->rpgPlot = $rpgPlot; |
|
230
|
|
|
|
|
231
|
|
|
return $this; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
public function getComments(): Collection |
|
235
|
|
|
{ |
|
236
|
|
|
return $this->comments; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
public function getRatings(): array |
|
240
|
|
|
{ |
|
241
|
|
|
return $this->ratings; |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
public function setRatings(array $ratings): KnPostInterface |
|
245
|
|
|
{ |
|
246
|
|
|
$this->ratings = $ratings; |
|
247
|
|
|
return $this; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
public function getUrl(): string |
|
251
|
|
|
{ |
|
252
|
|
|
return sprintf( |
|
253
|
|
|
'/comm.php?%s=1&id=%d', |
|
254
|
|
|
ShowSingleKn::VIEW_IDENTIFIER, |
|
255
|
|
|
$this->getId() |
|
256
|
|
|
); |
|
257
|
|
|
} |
|
258
|
|
|
} |
|
259
|
|
|
|