1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Entity; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
7
|
|
|
use Doctrine\Common\Collections\Collection; |
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @ORM\Entity |
12
|
|
|
* @ORM\Table(name="forums") |
13
|
|
|
*/ |
14
|
|
|
class Forum |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var int |
18
|
|
|
* @ORM\Id |
19
|
|
|
* @ORM\GeneratedValue |
20
|
|
|
* @ORM\Column(type="integer") |
21
|
|
|
*/ |
22
|
|
|
protected $id; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
* @ORM\Column(type="string", unique=true, length=191) |
27
|
|
|
*/ |
28
|
|
|
protected $name; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
* @ORM\Column(type="string", unique=true, length=191) |
33
|
|
|
*/ |
34
|
|
|
protected $url; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var User |
38
|
|
|
* @ORM\ManyToOne(targetEntity="\App\Entity\User") |
39
|
|
|
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id", nullable=false) |
40
|
|
|
*/ |
41
|
|
|
protected $owner; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var bool |
45
|
|
|
* @ORM\Column(type="boolean", options={"default": false}) |
46
|
|
|
*/ |
47
|
|
|
protected $closed = false; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string|null |
51
|
|
|
* @ORM\Column(type="string", nullable=true) |
52
|
|
|
*/ |
53
|
|
|
protected $closed_message; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var array|null |
57
|
|
|
* @ORM\Column(type="array", nullable=true) |
58
|
|
|
*/ |
59
|
|
|
protected $keywords; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var string|null |
63
|
|
|
* @ORM\Column(type="string", nullable=true) |
64
|
|
|
*/ |
65
|
|
|
protected $description; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var string|null |
69
|
|
|
* @ORM\Column(type="string", nullable=true) |
70
|
|
|
*/ |
71
|
|
|
protected $google_analytics_id; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var string|null |
75
|
|
|
* @ORM\Column(type="string", nullable=true) |
76
|
|
|
*/ |
77
|
|
|
protected $google_web_developer; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var array|null |
81
|
|
|
* @ORM\Column(type="array", nullable=true) |
82
|
|
|
*/ |
83
|
|
|
protected $links; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var string|null |
87
|
|
|
* @ORM\Column(type="string", nullable=true, options={"default": "en-US"}) |
88
|
|
|
*/ |
89
|
|
|
protected $language; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var string|null |
93
|
|
|
* @ORM\Column(type="string", nullable=true) |
94
|
|
|
*/ |
95
|
|
|
protected $copyright; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @var DateTime |
99
|
|
|
* @ORM\Column(type="datetime") |
100
|
|
|
*/ |
101
|
|
|
protected $created; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @var Collection |
105
|
|
|
* @ORM\OneToMany(targetEntity="Board", mappedBy="forum", cascade={"persist", "remove"}, orphanRemoval=true) |
106
|
|
|
*/ |
107
|
|
|
protected $boards; |
108
|
|
|
|
109
|
|
|
public function __construct() |
110
|
|
|
{ |
111
|
|
|
$this->boards = new ArrayCollection(); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return int The ID |
116
|
|
|
*/ |
117
|
|
|
public function getId(): int |
118
|
|
|
{ |
119
|
|
|
return $this->id; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return string The name |
124
|
|
|
*/ |
125
|
|
|
public function getName(): string |
126
|
|
|
{ |
127
|
|
|
return $this->name; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param string $name The name |
132
|
|
|
* |
133
|
|
|
* @return $this |
134
|
|
|
*/ |
135
|
|
|
public function setName(string $name): self |
136
|
|
|
{ |
137
|
|
|
$this->name = $name; |
138
|
|
|
|
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return string The url |
144
|
|
|
*/ |
145
|
|
|
public function getUrl(): string |
146
|
|
|
{ |
147
|
|
|
return $this->url; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @param string $url The url |
152
|
|
|
* |
153
|
|
|
* @return $this |
154
|
|
|
*/ |
155
|
|
|
public function setUrl(string $url): self |
156
|
|
|
{ |
157
|
|
|
$this->url = $url; |
158
|
|
|
|
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return User The owner |
164
|
|
|
*/ |
165
|
|
|
public function getOwner(): User |
166
|
|
|
{ |
167
|
|
|
return $this->owner; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param User $owner The owner |
172
|
|
|
* |
173
|
|
|
* @return $this |
174
|
|
|
*/ |
175
|
|
|
public function setOwner(User $owner): self |
176
|
|
|
{ |
177
|
|
|
$this->owner = $owner; |
178
|
|
|
|
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return bool Whether the forum is closed |
184
|
|
|
*/ |
185
|
|
|
public function isClosed(): bool |
186
|
|
|
{ |
187
|
|
|
return $this->closed; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @param bool $closed Whether the forum is closed |
192
|
|
|
* |
193
|
|
|
* @return $this |
194
|
|
|
*/ |
195
|
|
|
public function setClosed(bool $closed): self |
196
|
|
|
{ |
197
|
|
|
$this->closed = $closed; |
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @return string|null The message why the forum was closed |
204
|
|
|
*/ |
205
|
|
|
public function getClosedMessage(): ?string |
206
|
|
|
{ |
207
|
|
|
return $this->closed_message; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @param string|null $closed_message The message why the forum was closed |
212
|
|
|
* |
213
|
|
|
* @return $this |
214
|
|
|
*/ |
215
|
|
|
public function setClosedMessage(string $closed_message = null): self |
216
|
|
|
{ |
217
|
|
|
$this->closed_message = $closed_message; |
218
|
|
|
|
219
|
|
|
return $this; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @return array|null The keywords |
224
|
|
|
*/ |
225
|
|
|
public function getKeywords(): ?array |
226
|
|
|
{ |
227
|
|
|
return $this->keywords; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @param string $keyword The keyword |
232
|
|
|
* |
233
|
|
|
* @return $this |
234
|
|
|
*/ |
235
|
|
|
public function addKeyword(string $keyword): self |
236
|
|
|
{ |
237
|
|
|
if (!is_array($this->keywords)) { |
238
|
|
|
$this->keywords = []; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
$array = new ArrayCollection($this->keywords); |
242
|
|
|
$array->add($keyword); |
243
|
|
|
$this->keywords = $array->toArray(); |
244
|
|
|
|
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* @param string $keyword The keyword |
250
|
|
|
* |
251
|
|
|
* @return $this |
252
|
|
|
*/ |
253
|
|
|
public function removeKeyword(string $keyword): self |
254
|
|
|
{ |
255
|
|
|
if (!is_array($this->keywords)) { |
256
|
|
|
$this->keywords = []; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
$array = new ArrayCollection($this->keywords); |
260
|
|
|
if ($array->contains($keyword)) { |
261
|
|
|
$array->removeElement($keyword); |
262
|
|
|
$this->keywords = $array->toArray(); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return string|null The description |
270
|
|
|
*/ |
271
|
|
|
public function getDescription(): ?string |
272
|
|
|
{ |
273
|
|
|
return $this->description; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param string|null $description The description |
278
|
|
|
* |
279
|
|
|
* @return $this |
280
|
|
|
*/ |
281
|
|
|
public function setDescription(string $description = null): self |
282
|
|
|
{ |
283
|
|
|
$this->description = $description; |
284
|
|
|
|
285
|
|
|
return $this; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @return string|null The Google Analytics ID |
290
|
|
|
*/ |
291
|
|
|
public function getGoogleAnalyticsId(): ?string |
292
|
|
|
{ |
293
|
|
|
return $this->google_analytics_id; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @param string|null $id The Google Analytics ID |
298
|
|
|
* |
299
|
|
|
* @return $this |
300
|
|
|
*/ |
301
|
|
|
public function setGoogleAnalyticsId(string $id = null): self |
302
|
|
|
{ |
303
|
|
|
$this->google_analytics_id = $id; |
304
|
|
|
|
305
|
|
|
return $this; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* @return string|null The Google Web Developer ID |
310
|
|
|
*/ |
311
|
|
|
public function getGoogleWebDeveloper(): ?string |
312
|
|
|
{ |
313
|
|
|
return $this->google_web_developer; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* @param string|null $google_web_dev The Google Web Developer ID |
318
|
|
|
* |
319
|
|
|
* @return $this |
320
|
|
|
*/ |
321
|
|
|
public function setGoogleWebDeveloper(string $google_web_dev = null): self |
322
|
|
|
{ |
323
|
|
|
$this->google_web_developer = $google_web_dev; |
324
|
|
|
|
325
|
|
|
return $this; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @return array|null The links |
330
|
|
|
*/ |
331
|
|
|
public function getLinks(): ?array |
332
|
|
|
{ |
333
|
|
|
return $this->links; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* @param array|null $links The links |
338
|
|
|
* |
339
|
|
|
* @return $this |
340
|
|
|
*/ |
341
|
|
|
public function setLinks(array $links = null): self |
342
|
|
|
{ |
343
|
|
|
$this->links = $links; |
344
|
|
|
|
345
|
|
|
return $this; |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
/** |
349
|
|
|
* @return string|null The language |
350
|
|
|
*/ |
351
|
|
|
public function getLanguage(): ?string |
352
|
|
|
{ |
353
|
|
|
return $this->language; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* @param string|null $language The language |
358
|
|
|
* |
359
|
|
|
* @return $this |
360
|
|
|
*/ |
361
|
|
|
public function setLanguage(string $language = null): self |
362
|
|
|
{ |
363
|
|
|
$this->language = $language; |
364
|
|
|
|
365
|
|
|
return $this; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* @return string|null The copyright notice |
370
|
|
|
*/ |
371
|
|
|
public function getCopyright(): ?string |
372
|
|
|
{ |
373
|
|
|
return $this->copyright; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* @param string|null $copyright The copyright notice |
378
|
|
|
* |
379
|
|
|
* @return $this |
380
|
|
|
*/ |
381
|
|
|
public function setCopyright(string $copyright = null): self |
382
|
|
|
{ |
383
|
|
|
$this->copyright = $copyright; |
384
|
|
|
|
385
|
|
|
return $this; |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
/** |
389
|
|
|
* @return DateTime The creation date |
390
|
|
|
*/ |
391
|
|
|
public function getCreated(): DateTime |
392
|
|
|
{ |
393
|
|
|
return $this->created; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* @param DateTime $created The creation date |
398
|
|
|
* |
399
|
|
|
* @return $this |
400
|
|
|
*/ |
401
|
|
|
public function setCreated(DateTime $created): self |
402
|
|
|
{ |
403
|
|
|
$this->created = $created; |
404
|
|
|
|
405
|
|
|
return $this; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
/** |
409
|
|
|
* @return Board[] The boards |
410
|
|
|
*/ |
411
|
|
|
public function getBoards(): array |
412
|
|
|
{ |
413
|
|
|
return $this->boards->toArray(); |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
/** |
417
|
|
|
* @param Board $board The board |
418
|
|
|
* |
419
|
|
|
* @return $this |
420
|
|
|
*/ |
421
|
|
|
public function addBoard(Board $board): self |
422
|
|
|
{ |
423
|
|
|
$this->boards->add($board); |
424
|
|
|
$board->setForum($this); |
425
|
|
|
|
426
|
|
|
return $this; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* @param Board $board The boards |
431
|
|
|
* |
432
|
|
|
* @return $this |
433
|
|
|
*/ |
434
|
|
|
public function removeBoard(Board $board): self |
435
|
|
|
{ |
436
|
|
|
if ($this->boards->contains($board)) { |
437
|
|
|
$this->boards->removeElement($board); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
return $this; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* @return array An array of all the properties of an object |
445
|
|
|
*/ |
446
|
|
|
public function toArray(): array |
447
|
|
|
{ |
448
|
|
|
return [ |
449
|
|
|
'id' => $this->id, |
450
|
|
|
'name' => $this->name, |
451
|
|
|
'url' => $this->url, |
452
|
|
|
'owner' => $this->owner, |
453
|
|
|
'closed' => $this->closed, |
454
|
|
|
'closed_message' => $this->closed_message, |
455
|
|
|
'keywords' => $this->keywords, |
456
|
|
|
'description' => $this->description, |
457
|
|
|
'google_analytics_id' => $this->google_analytics_id, |
458
|
|
|
'google_web_developer' => $this->google_web_developer, |
459
|
|
|
'links' => $this->links, |
460
|
|
|
'language' => $this->language, |
461
|
|
|
'copyright' => $this->copyright, |
462
|
|
|
'created' => $this->created, |
463
|
|
|
]; |
464
|
|
|
} |
465
|
|
|
} |
466
|
|
|
|