1 | <?php |
||
21 | class Image implements ImageInterface |
||
22 | { |
||
23 | use TimestampableTrait; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * Uploaded file extension. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $fileExtension; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $assetId; |
||
41 | |||
42 | /** |
||
43 | * @var ArticleMediaInterface |
||
44 | */ |
||
45 | protected $media; |
||
46 | |||
47 | /** |
||
48 | * @var int |
||
49 | */ |
||
50 | protected $width; |
||
51 | |||
52 | /** |
||
53 | * @var int |
||
54 | */ |
||
55 | protected $height; |
||
56 | |||
57 | /** |
||
58 | * @var ArrayCollection |
||
59 | */ |
||
60 | protected $renditions; |
||
61 | |||
62 | protected $variants = []; |
||
63 | |||
64 | /** |
||
65 | * File constructor. |
||
66 | */ |
||
67 | public function __construct() |
||
68 | { |
||
69 | $this->setCreatedAt(new \DateTime()); |
||
70 | $this->setRenditions(new ArrayCollection()); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @return ArticleMediaInterface |
||
75 | */ |
||
76 | public function getMedia(): ArticleMediaInterface |
||
77 | { |
||
78 | return $this->media; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param ArticleMediaInterface $media |
||
83 | */ |
||
84 | public function setMedia(ArticleMediaInterface $media) |
||
85 | { |
||
86 | $this->media = $media; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @param string $id |
||
91 | */ |
||
92 | public function setId($id) |
||
93 | { |
||
94 | $this->id = $id; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function getId() |
||
101 | { |
||
102 | return $this->id; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | public function setFileExtension($extension) |
||
109 | { |
||
110 | $this->fileExtension = $extension; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | public function getFileExtension() |
||
117 | { |
||
118 | return $this->fileExtension; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @return string |
||
123 | */ |
||
124 | public function getAssetId(): string |
||
125 | { |
||
126 | return $this->assetId; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | public function setAssetId(string $assetId) |
||
133 | { |
||
134 | $this->assetId = $assetId; |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @return ArrayCollection |
||
139 | */ |
||
140 | public function getRenditions() |
||
141 | { |
||
142 | return $this->renditions; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * @param ImageRendition $rendition |
||
147 | */ |
||
148 | public function addRendition(ImageRendition $rendition) |
||
149 | { |
||
150 | $this->renditions->add($rendition); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @param ArrayCollection $renditions |
||
155 | */ |
||
156 | public function setRenditions($renditions) |
||
157 | { |
||
158 | $this->renditions = $renditions; |
||
159 | } |
||
160 | |||
161 | public function getWidth(): int |
||
165 | |||
166 | public function setWidth(int $width): void |
||
167 | { |
||
168 | $this->width = $width; |
||
169 | } |
||
170 | |||
171 | public function getHeight(): int |
||
172 | { |
||
173 | return $this->height; |
||
174 | } |
||
175 | |||
176 | public function setHeight(int $height): void |
||
177 | { |
||
178 | $this->height = $height; |
||
179 | } |
||
180 | |||
181 | public function getVariants(): array |
||
185 | |||
186 | public function setVariants(array $variants): void |
||
190 | |||
191 | public function addVariant(string $variant): void |
||
197 | |||
198 | public function hasVariant(string $variant): bool |
||
202 | } |
||
203 |