|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
9
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
10
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
11
|
|
|
use Doctrine\ORM\Mapping\Index; |
|
12
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
13
|
|
|
use Stu\Orm\Repository\NewsRepository; |
|
14
|
|
|
|
|
15
|
|
|
#[Table(name: 'stu_news')] |
|
16
|
|
|
#[Index(name: 'news_date_idx', columns: ['date'])] |
|
17
|
|
|
#[Entity(repositoryClass: NewsRepository::class)] |
|
18
|
|
|
class News |
|
19
|
|
|
{ |
|
20
|
|
|
#[Id] |
|
21
|
|
|
#[Column(type: 'integer')] |
|
22
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
23
|
|
|
private int $id; |
|
24
|
|
|
|
|
25
|
|
|
#[Column(type: 'string')] |
|
26
|
|
|
private string $subject = ''; |
|
27
|
|
|
|
|
28
|
|
|
#[Column(type: 'text')] |
|
29
|
|
|
private string $text = ''; |
|
30
|
|
|
|
|
31
|
|
|
#[Column(type: 'integer')] |
|
32
|
|
|
private int $date = 0; |
|
33
|
|
|
|
|
34
|
|
|
#[Column(type: 'text')] |
|
35
|
|
|
private string $refs = ''; |
|
36
|
|
|
|
|
37
|
|
|
#[Column(type: 'boolean', nullable: true)] |
|
38
|
|
|
private ?bool $is_changelog = null; |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
public function getId(): int |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->id; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getSubject(): string |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->subject; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function setSubject(string $subject): News |
|
52
|
|
|
{ |
|
53
|
|
|
$this->subject = $subject; |
|
54
|
|
|
|
|
55
|
|
|
return $this; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getText(): string |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->text; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function setText(string $text): News |
|
64
|
|
|
{ |
|
65
|
|
|
$this->text = $text; |
|
66
|
|
|
|
|
67
|
|
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function getDate(): int |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->date; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function setDate(int $date): News |
|
76
|
|
|
{ |
|
77
|
|
|
$this->date = $date; |
|
78
|
|
|
|
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getRefs(): string |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->refs; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function setRefs(string $refs): News |
|
88
|
|
|
{ |
|
89
|
|
|
$this->refs = $refs; |
|
90
|
|
|
|
|
91
|
|
|
return $this; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function isChangelog(): ?bool |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->is_changelog; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function setChangelog(?bool $isChangelog): News |
|
100
|
|
|
{ |
|
101
|
|
|
$this->is_changelog = $isChangelog; |
|
102
|
|
|
|
|
103
|
|
|
return $this; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return array<string> |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getLinks(): array |
|
110
|
|
|
{ |
|
111
|
|
|
if ($this->getRefs() === '') { |
|
112
|
|
|
return []; |
|
113
|
|
|
} |
|
114
|
|
|
return explode("\n", $this->getRefs()); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|