Version 1
[yaffs-website] / web / modules / contrib / video_embed_field / src / ProviderPluginInterface.php
1 <?php
2
3 namespace Drupal\video_embed_field;
4
5 /**
6  * Providers an interface for embed providers.
7  */
8 interface ProviderPluginInterface {
9
10   /**
11    * Check if the plugin is applicable to the user input.
12    *
13    * @param string $input
14    *   User input to check if it's a URL for the given provider.
15    *
16    * @return bool
17    *   If the plugin works for the given URL.
18    */
19   public static function isApplicable($input);
20
21   /**
22    * Render a thumbnail.
23    *
24    * @param string $image_style
25    *   The quality of the thumbnail to render.
26    * @param string $link_url
27    *   Where the thumbnail should be linked to.
28    *
29    * @return array
30    *   A renderable array of a thumbnail.
31    */
32   public function renderThumbnail($image_style, $link_url);
33
34   /**
35    * Get the URL of the remote thumbnail.
36    *
37    * This is used to download the remote thumbnail and place it on the local
38    * file system so that it can be rendered with image styles. This is only
39    * called if no existing file is found for the thumbnail and should not be
40    * called unnecessarily, as it might query APIs for video thumbnail
41    * information.
42    *
43    * @return string
44    *   The URL to the remote thumbnail file.
45    */
46   public function getRemoteThumbnailUrl();
47
48   /**
49    * Get the URL to the local thumbnail.
50    *
51    * This method does not gartunee that the file will exist, only that it will
52    * be the location of the thumbnail after the download thumbnail method has
53    * been called.
54    *
55    * @return string
56    *   The URI for the local thumbnail.
57    */
58   public function getLocalThumbnailUri();
59
60   /**
61    * Download the remote thumbnail URL to the local thumbnail URI.
62    */
63   public function downloadThumbnail();
64
65   /**
66    * Render embed code.
67    *
68    * @param string $width
69    *   The width of the video player.
70    * @param string $height
71    *   The height of the video player.
72    * @param bool $autoplay
73    *   If the video should autoplay.
74    *
75    * @return mixed
76    *   A renderable array of the embed code.
77    */
78   public function renderEmbedCode($width, $height, $autoplay);
79
80   /**
81    * Get the ID of the video from user input.
82    *
83    * @param string $input
84    *   Input a user would enter into a video field.
85    *
86    * @return string
87    *   The ID in whatever format makes sense for the provider.
88    */
89   public static function getIdFromInput($input);
90
91   /**
92    * Get the name of the video.
93    *
94    * @return string
95    *   A name to represent the video for the given plugin.
96    */
97   public function getName();
98
99 }