Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / media_entity / src / MediaTypeInterface.php
1 <?php
2
3 namespace Drupal\media_entity;
4
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\Component\Plugin\ConfigurablePluginInterface;
7 use Drupal\Core\Plugin\PluginFormInterface;
8
9 /**
10  * Defines the interface for media types.
11  */
12 interface MediaTypeInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface {
13
14   /**
15    * Returns the display label.
16    *
17    * @return string
18    *   The display label.
19    */
20   public function label();
21
22   /**
23    * Gets list of fields provided by this plugin.
24    *
25    * @return array
26    *   Associative array with field names as keys and descriptions as values.
27    */
28   public function providedFields();
29
30   /**
31    * Gets a media-related field/value.
32    *
33    * @param MediaInterface $media
34    *   Media object.
35    * @param string $name
36    *   Name of field to fetch.
37    *
38    * @return mixed
39    *   Field value or FALSE if data unavailable.
40    */
41   public function getField(MediaInterface $media, $name);
42
43   /**
44    * Attaches type-specific constraints to media.
45    *
46    * @param MediaInterface $media
47    *   Media entity.
48    */
49   public function attachConstraints(MediaInterface $media);
50
51   /**
52    * Gets thumbnail image.
53    *
54    * Media type plugin is responsible for returning URI of the generic thumbnail
55    * if no other is available. This functions should always return a valid URI.
56    *
57    * @param MediaInterface $media
58    *   Media.
59    *
60    * @return string
61    *   URI of the thumbnail.
62    */
63   public function thumbnail(MediaInterface $media);
64
65   /**
66    * Gets the default thumbnail image.
67    *
68    * @return string
69    *   Uri of the default thumbnail image.
70    */
71   public function getDefaultThumbnail();
72
73   /**
74    * Provide a default name for the media.
75    *
76    * Plugins defining media bundles are suggested to override this method and
77    * provide a default name, to be used when there is no user-defined label
78    * available.
79    *
80    * @param \Drupal\media_entity\MediaInterface $media
81    *   The media object.
82    *
83    * @return string
84    *   The string that should be used as default media name.
85    */
86   public function getDefaultName(MediaInterface $media);
87
88 }