1 | <?php |
||
11 | class VimeoServiceAdapter extends AbstractServiceAdapter |
||
12 | { |
||
13 | const THUMBNAIL_SMALL = 'thumbnail_small'; |
||
14 | const THUMBNAIL_MEDIUM = 'thumbnail_medium'; |
||
15 | const THUMBNAIL_LARGE = 'thumbnail_large'; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | public $title; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | public $description; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | public $thumbnails; |
||
31 | |||
32 | /** |
||
33 | * @param string $url |
||
34 | * @param string $pattern |
||
35 | * @param EmbedRendererInterface $renderer |
||
36 | * @throws ServiceApiNotAvailable |
||
37 | */ |
||
38 | public function __construct($url, $pattern, EmbedRendererInterface $renderer) |
||
56 | |||
57 | /** |
||
58 | * Returns the service name (ie: "Youtube" or "Vimeo"). |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getServiceName() |
||
66 | |||
67 | /** |
||
68 | * Returns if the service has a thumbnail image. |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | public function hasThumbnail() |
||
76 | |||
77 | /** |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getTitle() |
||
84 | |||
85 | /** |
||
86 | * @param string $title |
||
87 | */ |
||
88 | public function setTitle($title) |
||
92 | |||
93 | /** |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getDescription() |
||
100 | |||
101 | /** |
||
102 | * @param string $description |
||
103 | */ |
||
104 | public function setDescription($description) |
||
108 | |||
109 | /** |
||
110 | * @param array $thumbnails |
||
111 | */ |
||
112 | private function setThumbnails(array $thumbnails) |
||
118 | |||
119 | /** |
||
120 | * @param string $size |
||
121 | * @param bool $forceSecure |
||
122 | * @return string |
||
123 | * |
||
124 | * @throws InvalidThumbnailSizeException |
||
125 | * @throws InvalidUrlException |
||
126 | */ |
||
127 | public function getThumbnail($size, $forceSecure = false) |
||
140 | |||
141 | /** |
||
142 | * @param bool $forceAutoplay |
||
143 | * |
||
144 | * @return string |
||
145 | * @throws InvalidUrlException |
||
146 | */ |
||
147 | public function getEmbedUrl($forceAutoplay = false, $forceSecure = false) |
||
151 | |||
152 | /** |
||
153 | * Returns all thumbnails available sizes. |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | public function getThumbNailSizes() |
||
165 | |||
166 | /** |
||
167 | * Returns the small thumbnail's url. |
||
168 | * |
||
169 | * @param bool $forceSecure |
||
170 | * @return string |
||
171 | * @throws InvalidThumbnailSizeException |
||
172 | * @throws InvalidUrlException |
||
173 | */ |
||
174 | public function getSmallThumbnail($forceSecure = false) |
||
178 | |||
179 | /** |
||
180 | * Returns the medium thumbnail's url. |
||
181 | * |
||
182 | * @param bool $forceSecure |
||
183 | * @return string |
||
184 | * @throws InvalidThumbnailSizeException |
||
185 | * @throws InvalidUrlException |
||
186 | */ |
||
187 | public function getMediumThumbnail($forceSecure = false) |
||
191 | |||
192 | /** |
||
193 | * Returns the large thumbnail's url. |
||
194 | * |
||
195 | * @param bool $forceSecure |
||
196 | * @return string |
||
197 | * @throws InvalidThumbnailSizeException |
||
198 | * @throws InvalidUrlException |
||
199 | */ |
||
200 | public function getLargeThumbnail($forceSecure = false) |
||
204 | |||
205 | /** |
||
206 | * Returns the largest thumnbnaail's url. |
||
207 | * |
||
208 | * @param bool $forceSecure |
||
209 | * @return string |
||
210 | * @throws InvalidThumbnailSizeException |
||
211 | * @throws InvalidUrlException |
||
212 | */ |
||
213 | public function getLargestThumbnail($forceSecure = false) |
||
217 | |||
218 | /** |
||
219 | * @return bool |
||
220 | */ |
||
221 | public function isEmbeddable() |
||
225 | |||
226 | /** |
||
227 | * Uses the Vimeo video API to get video info. |
||
228 | * |
||
229 | * @todo make this better by using guzzle |
||
230 | * |
||
231 | * @return array |
||
232 | * |
||
233 | * @throws ServiceApiNotAvailable |
||
234 | */ |
||
235 | private function getVideoDataFromServiceApi($url) |
||
247 | } |
||
248 |