1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MovingImage\Client\VMPro\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use JMS\Serializer\Annotation\Type; |
7
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
8
|
|
|
use MovingImage\Meta\Interfaces\ChannelInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class Channel. |
12
|
|
|
* |
13
|
|
|
* @author Ruben Knol <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class Channel implements ChannelInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @Type("integer") |
19
|
|
|
* |
20
|
|
|
* @var int |
21
|
|
|
*/ |
22
|
|
|
private $id; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @Type("string") |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $name; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @Type("string") |
33
|
|
|
* |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $description; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @Type("array") |
40
|
|
|
* @SerializedName("customMetadata") |
41
|
|
|
* |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
private $customMetadata = []; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @Type("ArrayCollection<MovingImage\Client\VMPro\Entity\Channel>") |
48
|
|
|
* |
49
|
|
|
* @var ChannelInterface[] |
50
|
|
|
*/ |
51
|
|
|
private $children; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @Type("MovingImage\Client\VMPro\Entity\Channel") |
55
|
|
|
* |
56
|
|
|
* @var ChannelInterface |
57
|
|
|
*/ |
58
|
|
|
private $parent = null; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @Type("integer") |
62
|
|
|
* @SerializedName("parentId") |
63
|
|
|
*/ |
64
|
|
|
private $parentId = null; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
*/ |
69
|
|
|
public function getName() |
70
|
|
|
{ |
71
|
|
|
return $this->name; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
|
|
public function setName($name) |
78
|
|
|
{ |
79
|
|
|
$this->name = $name; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
|
|
public function getDescription() |
88
|
|
|
{ |
89
|
|
|
return $this->description; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
|
|
public function setDescription($description) |
96
|
|
|
{ |
97
|
|
|
$this->description = $description; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* {@inheritdoc} |
104
|
|
|
*/ |
105
|
|
|
public function getCustomMetadata() |
106
|
|
|
{ |
107
|
|
|
return $this->customMetadata; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* {@inheritdoc} |
112
|
|
|
*/ |
113
|
|
|
public function setCustomMetadata($customMetadata) |
114
|
|
|
{ |
115
|
|
|
$this->customMetadata = $customMetadata; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* {@inheritdoc} |
122
|
|
|
*/ |
123
|
|
|
public function getId() |
124
|
|
|
{ |
125
|
|
|
return $this->id; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* {@inheritdoc} |
130
|
|
|
*/ |
131
|
|
|
public function setId($id) |
132
|
|
|
{ |
133
|
|
|
$this->id = $id; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* {@inheritdoc} |
140
|
|
|
*/ |
141
|
|
|
public function getParent() |
142
|
|
|
{ |
143
|
|
|
return $this->parent; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* {@inheritdoc} |
148
|
|
|
*/ |
149
|
|
|
public function setParent(ChannelInterface $parent) |
150
|
|
|
{ |
151
|
|
|
$this->parent = $parent; |
152
|
|
|
$this->setParentId($parent->getId()); |
153
|
|
|
|
154
|
|
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function setParentOnChildren() |
158
|
|
|
{ |
159
|
|
|
/** @var Channel $child */ |
160
|
|
|
foreach ($this->getChildren() as $child) { |
161
|
|
|
$child->setParent($this); |
162
|
|
|
if (!$child->getChildren()->isEmpty()) { |
163
|
|
|
$child->setParentOnChildren(); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return int |
170
|
|
|
*/ |
171
|
|
|
public function getParentId() |
172
|
|
|
{ |
173
|
|
|
return $this->parentId; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param int $parentId |
178
|
|
|
* |
179
|
|
|
* @return Channel |
180
|
|
|
*/ |
181
|
|
|
public function setParentId($parentId) |
182
|
|
|
{ |
183
|
|
|
$this->parentId = $parentId; |
184
|
|
|
|
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* {@inheritdoc} |
190
|
|
|
*/ |
191
|
|
|
public function getChildren() |
192
|
|
|
{ |
193
|
|
|
if (is_null($this->children)) { |
194
|
|
|
$this->children = new ArrayCollection(); |
|
|
|
|
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
return $this->children; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @param ArrayCollection $children |
202
|
|
|
* |
203
|
|
|
* @return $this |
204
|
|
|
*/ |
205
|
|
|
public function setChildren($children) |
206
|
|
|
{ |
207
|
|
|
$this->children = $children; |
|
|
|
|
208
|
|
|
|
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* {@inheritdoc} |
214
|
|
|
*/ |
215
|
|
|
public function addChild(ChannelInterface $child) |
216
|
|
|
{ |
217
|
|
|
$this->getChildren()->add($child); |
218
|
|
|
|
219
|
|
|
return $this; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* {@inheritdoc} |
224
|
|
|
*/ |
225
|
|
|
public function removeChild(ChannelInterface $channel) |
226
|
|
|
{ |
227
|
|
|
$this->getChildren()->removeElement($channel); |
228
|
|
|
|
229
|
|
|
return $this; |
230
|
|
|
} |
231
|
|
|
} |
232
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..