1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainFoundation\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Loevgaard\DandomainFoundation\Entity\Generated\MediumInterface; |
8
|
|
|
use Loevgaard\DandomainFoundation\Entity\Generated\MediumTrait; |
9
|
|
|
use Loevgaard\DandomainFoundation; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @ORM\Entity() |
13
|
|
|
* @ORM\Table(name="loevgaard_dandomain_media") |
14
|
|
|
*/ |
15
|
|
|
class Medium implements MediumInterface |
16
|
|
|
{ |
17
|
|
|
use MediumTrait; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var int |
21
|
|
|
* |
22
|
|
|
* @ORM\Id |
23
|
|
|
* @ORM\GeneratedValue |
24
|
|
|
* @ORM\Column(type="integer") |
25
|
|
|
**/ |
26
|
|
|
protected $id; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var int |
30
|
|
|
* |
31
|
|
|
* @ORM\Column(type="integer", unique=true) |
32
|
|
|
*/ |
33
|
|
|
protected $externalId; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string|null |
37
|
|
|
* |
38
|
|
|
* @ORM\Column(nullable=true, type="string") |
39
|
|
|
*/ |
40
|
|
|
protected $height; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var array|null |
44
|
|
|
* |
45
|
|
|
* @ORM\Column(nullable=true, type="array") |
46
|
|
|
*/ |
47
|
|
|
protected $mediaTranslations; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var int|null |
51
|
|
|
* |
52
|
|
|
* @ORM\Column(nullable=true, type="integer") |
53
|
|
|
*/ |
54
|
|
|
protected $sortOrder; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string|null |
58
|
|
|
* |
59
|
|
|
* @ORM\Column(nullable=true, type="string") |
60
|
|
|
*/ |
61
|
|
|
protected $thumbnail; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var string|null |
65
|
|
|
* |
66
|
|
|
* @ORM\Column(nullable=true, type="string") |
67
|
|
|
*/ |
68
|
|
|
protected $thumbnailHeight; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var string|null |
72
|
|
|
* |
73
|
|
|
* @ORM\Column(nullable=true, type="string") |
74
|
|
|
*/ |
75
|
|
|
protected $thumbnailWidth; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var string|null |
79
|
|
|
* |
80
|
|
|
* @ORM\Column(nullable=true, type="string") |
81
|
|
|
*/ |
82
|
|
|
protected $url; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @var string|null |
86
|
|
|
* |
87
|
|
|
* @ORM\Column(nullable=true, type="string") |
88
|
|
|
*/ |
89
|
|
|
protected $width; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var Product[]|ArrayCollection |
93
|
|
|
*/ |
94
|
|
|
protected $products; |
95
|
|
|
|
96
|
|
|
public function __construct() |
97
|
|
|
{ |
98
|
|
|
$this->products = new ArrayCollection(); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Populates a medium based on the response from the Dandomain API |
103
|
|
|
* |
104
|
|
|
* See the properties here: |
105
|
|
|
* http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductDataService/help/operations/GetDataProduct |
106
|
|
|
* |
107
|
|
|
* @param \stdClass|array $data |
108
|
|
|
*/ |
109
|
|
|
public function populateFromApiResponse($data) |
110
|
|
|
{ |
111
|
|
|
$data = DandomainFoundation\objectToArray($data); |
112
|
|
|
|
113
|
|
|
$this |
114
|
|
|
->setExternalId($data['id']) |
115
|
|
|
->setHeight($data['height']) |
116
|
|
|
->setMediaTranslations($data['mediaTranslations']) |
117
|
|
|
->setSortorder($data['sortorder']) |
118
|
|
|
->setThumbnail($data['thumbnail']) |
119
|
|
|
->setThumbnailheight($data['thumbnailheight']) |
120
|
|
|
->setThumbnailwidth($data['thumbnailwidth']) |
121
|
|
|
->setUrl($data['url']) |
122
|
|
|
->setWidth($data['width']) |
123
|
|
|
; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return int |
128
|
|
|
*/ |
129
|
|
|
public function getId(): int |
130
|
|
|
{ |
131
|
|
|
return (int)$this->id; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @param int $id |
136
|
|
|
* @return Medium |
137
|
|
|
*/ |
138
|
|
|
public function setId(int $id) |
139
|
|
|
{ |
140
|
|
|
$this->id = $id; |
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return int |
146
|
|
|
*/ |
147
|
|
|
public function getExternalId(): int |
148
|
|
|
{ |
149
|
|
|
return (int)$this->externalId; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param int $externalId |
154
|
|
|
* @return Medium |
155
|
|
|
*/ |
156
|
|
|
public function setExternalId(int $externalId) |
157
|
|
|
{ |
158
|
|
|
$this->externalId = $externalId; |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return null|string |
164
|
|
|
*/ |
165
|
|
|
public function getHeight() |
166
|
|
|
{ |
167
|
|
|
return $this->height; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param null|string $height |
172
|
|
|
* @return Medium |
173
|
|
|
*/ |
174
|
|
|
public function setHeight($height) |
175
|
|
|
{ |
176
|
|
|
$this->height = $height; |
177
|
|
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return array|null |
182
|
|
|
*/ |
183
|
|
|
public function getMediaTranslations() |
184
|
|
|
{ |
185
|
|
|
return $this->mediaTranslations; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param array|null $mediaTranslations |
190
|
|
|
* @return Medium |
191
|
|
|
*/ |
192
|
|
|
public function setMediaTranslations($mediaTranslations) |
193
|
|
|
{ |
194
|
|
|
$this->mediaTranslations = $mediaTranslations; |
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @return int|null |
200
|
|
|
*/ |
201
|
|
|
public function getSortOrder() |
202
|
|
|
{ |
203
|
|
|
return $this->sortOrder; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @param int|null $sortOrder |
208
|
|
|
* @return Medium |
209
|
|
|
*/ |
210
|
|
|
public function setSortOrder($sortOrder) |
211
|
|
|
{ |
212
|
|
|
$this->sortOrder = $sortOrder; |
213
|
|
|
return $this; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return null|string |
218
|
|
|
*/ |
219
|
|
|
public function getThumbnail() |
220
|
|
|
{ |
221
|
|
|
return $this->thumbnail; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @param null|string $thumbnail |
226
|
|
|
* @return Medium |
227
|
|
|
*/ |
228
|
|
|
public function setThumbnail($thumbnail) |
229
|
|
|
{ |
230
|
|
|
$this->thumbnail = $thumbnail; |
231
|
|
|
return $this; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @return null|string |
236
|
|
|
*/ |
237
|
|
|
public function getThumbnailHeight() |
238
|
|
|
{ |
239
|
|
|
return $this->thumbnailHeight; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @param null|string $thumbnailHeight |
244
|
|
|
* @return Medium |
245
|
|
|
*/ |
246
|
|
|
public function setThumbnailHeight($thumbnailHeight) |
247
|
|
|
{ |
248
|
|
|
$this->thumbnailHeight = $thumbnailHeight; |
249
|
|
|
return $this; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @return null|string |
254
|
|
|
*/ |
255
|
|
|
public function getThumbnailWidth() |
256
|
|
|
{ |
257
|
|
|
return $this->thumbnailWidth; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @param null|string $thumbnailWidth |
262
|
|
|
* @return Medium |
263
|
|
|
*/ |
264
|
|
|
public function setThumbnailWidth($thumbnailWidth) |
265
|
|
|
{ |
266
|
|
|
$this->thumbnailWidth = $thumbnailWidth; |
267
|
|
|
return $this; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @return null|string |
272
|
|
|
*/ |
273
|
|
|
public function getUrl() |
274
|
|
|
{ |
275
|
|
|
return $this->url; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @param null|string $url |
280
|
|
|
* @return Medium |
281
|
|
|
*/ |
282
|
|
|
public function setUrl($url) |
283
|
|
|
{ |
284
|
|
|
$this->url = $url; |
285
|
|
|
return $this; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @return null|string |
290
|
|
|
*/ |
291
|
|
|
public function getWidth() |
292
|
|
|
{ |
293
|
|
|
return $this->width; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @param null|string $width |
298
|
|
|
* @return Medium |
299
|
|
|
*/ |
300
|
|
|
public function setWidth($width) |
301
|
|
|
{ |
302
|
|
|
$this->width = $width; |
303
|
|
|
return $this; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* @return ArrayCollection|Product[] |
308
|
|
|
*/ |
309
|
|
|
public function getProducts() |
310
|
|
|
{ |
311
|
|
|
return $this->products; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* @param ArrayCollection|Product[] $products |
316
|
|
|
* @return Medium |
317
|
|
|
*/ |
318
|
|
|
public function setProducts($products) |
319
|
|
|
{ |
320
|
|
|
$this->products = $products; |
321
|
|
|
return $this; |
322
|
|
|
} |
323
|
|
|
} |
324
|
|
|
|