Chris@17
|
1 <?php
|
Chris@17
|
2
|
Chris@17
|
3 namespace Drupal\media\OEmbed;
|
Chris@17
|
4
|
Chris@17
|
5 /**
|
Chris@17
|
6 * Defines the interface for the oEmbed URL resolver service.
|
Chris@17
|
7 *
|
Chris@17
|
8 * The URL resolver is responsible for converting oEmbed-compatible media asset
|
Chris@17
|
9 * URLs into canonical resource URLs, at which an oEmbed representation of the
|
Chris@17
|
10 * asset can be retrieved.
|
Chris@17
|
11 */
|
Chris@17
|
12 interface UrlResolverInterface {
|
Chris@17
|
13
|
Chris@17
|
14 /**
|
Chris@17
|
15 * Tries to determine the oEmbed provider for a media asset URL.
|
Chris@17
|
16 *
|
Chris@17
|
17 * @param string $url
|
Chris@17
|
18 * The media asset URL.
|
Chris@17
|
19 *
|
Chris@17
|
20 * @return \Drupal\media\OEmbed\Provider
|
Chris@17
|
21 * The oEmbed provider for the asset.
|
Chris@17
|
22 *
|
Chris@17
|
23 * @throws \Drupal\media\OEmbed\ResourceException
|
Chris@17
|
24 * If the provider cannot be determined.
|
Chris@17
|
25 * @throws \Drupal\media\OEmbed\ProviderException
|
Chris@17
|
26 * If tne oEmbed provider causes an error.
|
Chris@17
|
27 */
|
Chris@17
|
28 public function getProviderByUrl($url);
|
Chris@17
|
29
|
Chris@17
|
30 /**
|
Chris@17
|
31 * Builds the resource URL for a media asset URL.
|
Chris@17
|
32 *
|
Chris@17
|
33 * @param string $url
|
Chris@17
|
34 * The media asset URL.
|
Chris@17
|
35 * @param int $max_width
|
Chris@17
|
36 * (optional) Maximum width of the oEmbed resource, in pixels.
|
Chris@17
|
37 * @param int $max_height
|
Chris@17
|
38 * (optional) Maximum height of the oEmbed resource, in pixels.
|
Chris@17
|
39 *
|
Chris@17
|
40 * @return string
|
Chris@17
|
41 * Returns the resource URL corresponding to the given media item URL.
|
Chris@17
|
42 */
|
Chris@17
|
43 public function getResourceUrl($url, $max_width = NULL, $max_height = NULL);
|
Chris@17
|
44
|
Chris@17
|
45 }
|