1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace MovingImage\Client\VMPro\Entity; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
9
|
|
|
use JMS\Serializer\Annotation\Type; |
10
|
|
|
use MovingImage\Meta\Interfaces\ChannelInterface; |
11
|
|
|
|
12
|
|
|
class Channel implements ChannelInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @Type("integer") |
16
|
|
|
* |
17
|
|
|
* @var int |
18
|
|
|
*/ |
19
|
|
|
private $id; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @Type("string") |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private $name; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @Type("string") |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $description; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @Type("array") |
37
|
|
|
* @SerializedName("customMetadata") |
38
|
|
|
* |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
private $customMetadata = []; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @Type("ArrayCollection<MovingImage\Client\VMPro\Entity\Channel>") |
45
|
|
|
* |
46
|
|
|
* @var ArrayCollection<ChannelInterface> |
47
|
|
|
*/ |
48
|
|
|
private $children; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @Type("MovingImage\Client\VMPro\Entity\Channel") |
52
|
|
|
* |
53
|
|
|
* @var ChannelInterface |
54
|
|
|
*/ |
55
|
|
|
private $parent = null; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @Type("integer") |
59
|
|
|
* @SerializedName("parentId") |
60
|
|
|
*/ |
61
|
|
|
private $parentId = null; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @Type("MovingImage\Client\VMPro\Entity\Ownership") |
65
|
|
|
* |
66
|
|
|
* @var Ownership |
67
|
|
|
*/ |
68
|
|
|
private $ownership = null; |
69
|
|
|
|
70
|
|
|
public function getName(): string |
71
|
|
|
{ |
72
|
|
|
return $this->name; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setName(string $name): self |
76
|
|
|
{ |
77
|
|
|
$this->name = $name; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getDescription(): string |
83
|
|
|
{ |
84
|
|
|
return $this->description; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function setDescription(string $description): self |
88
|
|
|
{ |
89
|
|
|
$this->description = $description; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getCustomMetadata(): array |
95
|
|
|
{ |
96
|
|
|
return $this->customMetadata; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function setCustomMetadata($customMetadata): self |
100
|
|
|
{ |
101
|
|
|
$this->customMetadata = $customMetadata; |
102
|
|
|
|
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function getId(): int |
107
|
|
|
{ |
108
|
|
|
return $this->id; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
public function setId($id): self |
112
|
|
|
{ |
113
|
|
|
$this->id = $id; |
114
|
|
|
|
115
|
|
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function getParent(): ?ChannelInterface |
119
|
|
|
{ |
120
|
|
|
return $this->parent; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function setParent(ChannelInterface $parent): self |
124
|
|
|
{ |
125
|
|
|
$this->parent = $parent; |
126
|
|
|
$this->setParentId($parent->getId()); |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function setParentOnChildren(): self |
132
|
|
|
{ |
133
|
|
|
/** @var Channel $child */ |
134
|
|
|
foreach ($this->getChildren() as $child) { |
135
|
|
|
$child->setParent($this); |
136
|
|
|
if (!$child->getChildren()->isEmpty()) { |
137
|
|
|
$child->setParentOnChildren(); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function getParentId(): ?int |
145
|
|
|
{ |
146
|
|
|
return $this->parentId; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function setParentId(?int $parentId): self |
150
|
|
|
{ |
151
|
|
|
$this->parentId = $parentId; |
152
|
|
|
|
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* {@inheritdoc} |
158
|
|
|
*/ |
159
|
|
|
public function getChildren(): ArrayCollection |
160
|
|
|
{ |
161
|
|
|
if (is_null($this->children)) { |
162
|
|
|
$this->children = new ArrayCollection(); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
return $this->children; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function setChildren(ArrayCollection $children): self |
169
|
|
|
{ |
170
|
|
|
$this->children = $children; |
171
|
|
|
|
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function addChild(ChannelInterface $child): self |
176
|
|
|
{ |
177
|
|
|
$this->getChildren()->add($child); |
178
|
|
|
|
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function removeChild(ChannelInterface $channel): self |
183
|
|
|
{ |
184
|
|
|
$this->getChildren()->removeElement($channel); |
185
|
|
|
|
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
public function getOwnership(): Ownership |
190
|
|
|
{ |
191
|
|
|
return $this->ownership; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
public function setOwnership(Ownership $ownership): self |
195
|
|
|
{ |
196
|
|
|
$this->ownership = $ownership; |
197
|
|
|
|
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|