1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Superdesk Web Publisher Content Bundle. |
5
|
|
|
* |
6
|
|
|
* Copyright 2020 Sourcefabric z.ú. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2020 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
declare(strict_types=1); |
16
|
|
|
|
17
|
|
|
namespace SWP\Bundle\ContentBundle\Model; |
18
|
|
|
|
19
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
20
|
|
|
use Doctrine\Common\Collections\Collection; |
21
|
|
|
|
22
|
|
|
class Metadata implements MetadataInterface |
23
|
|
|
{ |
24
|
|
|
public const SERVICE_KEY = 'service'; |
25
|
|
|
|
26
|
|
|
public const SUBJECT_KEY = 'subject'; |
27
|
|
|
|
28
|
|
|
public const PLACE_KEY = 'place'; |
29
|
|
|
|
30
|
|
|
/** @var int */ |
31
|
|
|
protected $id; |
32
|
|
|
|
33
|
|
|
/** @var Collection|SubjectInterface[] */ |
34
|
|
|
protected $subjects; |
35
|
|
|
|
36
|
|
|
/** @var Collection|ServiceInterface[] */ |
37
|
|
|
protected $services; |
38
|
|
|
|
39
|
|
|
/** @var Collection|PlaceInterface[] */ |
40
|
|
|
protected $places; |
41
|
|
|
|
42
|
|
|
/** @var string|null */ |
43
|
|
|
protected $profile; |
44
|
|
|
|
45
|
|
|
/** @var string|null */ |
46
|
|
|
protected $guid; |
47
|
|
|
|
48
|
|
|
/** @var string|null */ |
49
|
|
|
protected $urgency; |
50
|
|
|
|
51
|
|
|
/** @var string|null */ |
52
|
|
|
protected $priority; |
53
|
|
|
|
54
|
|
|
/** @var string|null */ |
55
|
|
|
protected $located; |
56
|
|
|
|
57
|
|
|
/** @var string|null */ |
58
|
|
|
protected $byline; |
59
|
|
|
|
60
|
|
|
/** @var string|null */ |
61
|
|
|
protected $language; |
62
|
|
|
|
63
|
|
|
/** @var string|null */ |
64
|
|
|
protected $edNote; |
65
|
|
|
|
66
|
|
|
/** @var string|null */ |
67
|
|
|
protected $genre; |
68
|
|
|
|
69
|
|
|
/** @var ArticleInterface */ |
70
|
|
|
protected $article; |
71
|
|
|
|
72
|
|
|
public function __construct() |
73
|
|
|
{ |
74
|
|
|
$this->subjects = new ArrayCollection(); |
75
|
|
|
$this->services = new ArrayCollection(); |
76
|
|
|
$this->places = new ArrayCollection(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function getId(): int |
80
|
|
|
{ |
81
|
|
|
return $this->id; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getSubjects(): Collection |
85
|
|
|
{ |
86
|
|
|
return $this->subjects; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function addSubject(SubjectInterface $subject): void |
90
|
|
|
{ |
91
|
|
|
if (!$this->hasSubject($subject)) { |
92
|
|
|
$subject->setMetadata($this); |
93
|
|
|
$this->subjects->add($subject); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function removeSubject(SubjectInterface $subject): void |
98
|
|
|
{ |
99
|
|
|
if ($this->hasSubject($subject)) { |
100
|
|
|
$subject->setMetadata(null); |
101
|
|
|
$this->subjects->removeElement($subject); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function hasSubject(SubjectInterface $subject): bool |
106
|
|
|
{ |
107
|
|
|
return $this->subjects->contains($subject); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getServices(): Collection |
111
|
|
|
{ |
112
|
|
|
return $this->services; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function addService(ServiceInterface $service): void |
116
|
|
|
{ |
117
|
|
|
if (!$this->hasService($service)) { |
118
|
|
|
$service->setMetadata($this); |
119
|
|
|
$this->services->add($service); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function removeService(ServiceInterface $service): void |
124
|
|
|
{ |
125
|
|
|
if ($this->hasService($service)) { |
126
|
|
|
$service->setMetadata(null); |
127
|
|
|
$this->services->removeElement($service); |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function hasService(ServiceInterface $service): bool |
132
|
|
|
{ |
133
|
|
|
return $this->services->contains($service); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function getPlaces(): Collection |
137
|
|
|
{ |
138
|
|
|
return $this->places; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function addPlace(PlaceInterface $place): void |
142
|
|
|
{ |
143
|
|
|
if (!$this->hasPlace($place)) { |
144
|
|
|
$place->setMetadata($this); |
145
|
|
|
$this->places->add($place); |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function removePlace(PlaceInterface $place): void |
150
|
|
|
{ |
151
|
|
|
if ($this->hasPlace($place)) { |
152
|
|
|
$place->setMetadata(null); |
153
|
|
|
$this->places->removeElement($place); |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function hasPlace(PlaceInterface $place): bool |
158
|
|
|
{ |
159
|
|
|
return $this->places->contains($place); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function getProfile(): ?string |
163
|
|
|
{ |
164
|
|
|
return $this->profile; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function setProfile(?string $profile): void |
168
|
|
|
{ |
169
|
|
|
$this->profile = $profile; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function getGuid(): ?string |
173
|
|
|
{ |
174
|
|
|
return $this->guid; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
public function setGuid(?string $guid): void |
178
|
|
|
{ |
179
|
|
|
$this->guid = $guid; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function getUrgency(): ?int |
183
|
|
|
{ |
184
|
|
|
return $this->urgency; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function setUrgency(?int $urgency): void |
188
|
|
|
{ |
189
|
|
|
$this->urgency = $urgency; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function getPriority(): ?int |
193
|
|
|
{ |
194
|
|
|
return $this->priority; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
public function setPriority(?int $priority): void |
198
|
|
|
{ |
199
|
|
|
$this->priority = $priority; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function getLocated(): ?string |
203
|
|
|
{ |
204
|
|
|
return $this->located; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
public function setLocated(?string $located): void |
208
|
|
|
{ |
209
|
|
|
$this->located = $located; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
public function getByline(): ?string |
213
|
|
|
{ |
214
|
|
|
return $this->byline; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function setByline(?string $byline): void |
218
|
|
|
{ |
219
|
|
|
$this->byline = $byline; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
public function getLanguage(): ?string |
223
|
|
|
{ |
224
|
|
|
return $this->language; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
public function setLanguage(?string $language): void |
228
|
|
|
{ |
229
|
|
|
$this->language = $language; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public function getEdNote(): ?string |
233
|
|
|
{ |
234
|
|
|
return $this->edNote; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function setEdNote(?string $edNote): void |
238
|
|
|
{ |
239
|
|
|
$this->edNote = $edNote; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
public function getGenre(): ?string |
243
|
|
|
{ |
244
|
|
|
return $this->genre; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
public function setGenre(?string $genre): void |
248
|
|
|
{ |
249
|
|
|
$this->genre = $genre; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
public function getArticle(): ?ArticleInterface |
253
|
|
|
{ |
254
|
|
|
return $this->article; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
public function setArticle(?ArticleInterface $article): void |
258
|
|
|
{ |
259
|
|
|
$this->article = $article; |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
|