1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Superdesk Web Publisher Content Bundle. |
5
|
|
|
* |
6
|
|
|
* Copyright 2016 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 2016 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SWP\Bundle\ContentBundle\Model; |
16
|
|
|
|
17
|
|
|
use SWP\Component\Common\Model\TimestampableTrait; |
18
|
|
|
|
19
|
|
|
class Image implements ImageInterface |
20
|
|
|
{ |
21
|
|
|
use TimestampableTrait; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $id; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Uploaded file extension. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $fileExtension; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $assetId; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var ArticleMediaInterface |
42
|
|
|
*/ |
43
|
|
|
protected $media; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var int |
47
|
|
|
*/ |
48
|
|
|
protected $width; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var int |
52
|
|
|
*/ |
53
|
|
|
protected $height; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var ImageRenditionInterface |
57
|
|
|
*/ |
58
|
|
|
protected $rendition; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* File constructor. |
62
|
|
|
*/ |
63
|
|
|
public function __construct() |
64
|
|
|
{ |
65
|
|
|
$this->setCreatedAt(new \DateTime()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return ArticleMediaInterface |
70
|
|
|
*/ |
71
|
|
|
public function getMedia(): ArticleMediaInterface |
72
|
|
|
{ |
73
|
|
|
return $this->media; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param ArticleMediaInterface $media |
78
|
|
|
*/ |
79
|
|
|
public function setMedia(ArticleMediaInterface $media) |
80
|
|
|
{ |
81
|
|
|
$this->media = $media; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $id |
86
|
|
|
*/ |
87
|
|
|
public function setId($id) |
88
|
|
|
{ |
89
|
|
|
$this->id = $id; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
|
|
public function getId() |
96
|
|
|
{ |
97
|
|
|
return $this->id; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* {@inheritdoc} |
102
|
|
|
*/ |
103
|
|
|
public function setFileExtension($extension) |
104
|
|
|
{ |
105
|
|
|
$this->fileExtension = $extension; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* {@inheritdoc} |
110
|
|
|
*/ |
111
|
|
|
public function getFileExtension() |
112
|
|
|
{ |
113
|
|
|
return $this->fileExtension; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
|
|
public function getAssetId(): string |
120
|
|
|
{ |
121
|
|
|
return $this->assetId; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* {@inheritdoc} |
126
|
|
|
*/ |
127
|
|
|
public function setAssetId(string $assetId) |
128
|
|
|
{ |
129
|
|
|
$this->assetId = $assetId; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return ImageRenditionInterface |
134
|
|
|
*/ |
135
|
|
|
public function getRendition() |
136
|
|
|
{ |
137
|
|
|
return $this->rendition; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param ImageRenditionInterface $rendition |
142
|
|
|
*/ |
143
|
|
|
public function setRendition(ImageRenditionInterface $rendition) |
144
|
|
|
{ |
145
|
|
|
$this->rendition = $rendition; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* {@inheritdoc} |
150
|
|
|
*/ |
151
|
|
|
public function getWidth() |
152
|
|
|
{ |
153
|
|
|
return $this->width; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Set the value of Width. |
158
|
|
|
* |
159
|
|
|
* @param int $width |
160
|
|
|
* |
161
|
|
|
* @return self |
162
|
|
|
*/ |
163
|
|
|
public function setWidth($width) |
164
|
|
|
{ |
165
|
|
|
$this->width = $width; |
166
|
|
|
|
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* {@inheritdoc} |
172
|
|
|
*/ |
173
|
|
|
public function getHeight() |
174
|
|
|
{ |
175
|
|
|
return $this->height; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Set the value of Height. |
180
|
|
|
* |
181
|
|
|
* @param int $height |
182
|
|
|
* |
183
|
|
|
* @return self |
184
|
|
|
*/ |
185
|
|
|
public function setHeight($height) |
186
|
|
|
{ |
187
|
|
|
$this->height = $height; |
188
|
|
|
|
189
|
|
|
return $this; |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|