3 namespace Drupal\media;
5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
6 use Drupal\Core\Entity\EntityDescriptionInterface;
7 use Drupal\Core\Entity\RevisionableEntityBundleInterface;
10 * Provides an interface defining a media type entity.
12 * Media types are bundles for media items. They are used to group media with
13 * the same semantics. Media types are not about where media comes from. They
14 * are about the semantics that media has in the context of a given Drupal site.
16 * Media sources, on the other hand, are aware where media comes from and know
17 * how to represent and handle it in Drupal's context. They are aware of the low
18 * level details, while the media types don't care about them at all. That said,
19 * media types can not exist without media sources.
21 * Consider the following examples:
22 * - oEmbed media source which can represent any oEmbed resource. Media types
23 * that could be used with this source are "Videos", "Charts", "Music", etc.
24 * All of them are retrieved using the same protocol, but they represent very
26 * - Media sources that represent files could be used with media types like
27 * "Invoices", "Subtitles", "Meeting notes", etc. They are all files stored on
28 * some kind of storage, but their meaning and uses in a Drupal site are
31 * @see \Drupal\media\MediaSourceInterface
33 interface MediaTypeInterface extends ConfigEntityInterface, EntityDescriptionInterface, RevisionableEntityBundleInterface {
36 * Returns whether thumbnail downloads are queued.
39 * TRUE if thumbnails are queued for download later, FALSE if they should be
42 public function thumbnailDownloadsAreQueued();
45 * Sets a flag to indicate that thumbnails should be downloaded via a queue.
47 * @param bool $queue_thumbnail_downloads
48 * The queue downloads flag.
52 public function setQueueThumbnailDownloadsStatus($queue_thumbnail_downloads);
55 * Returns the media source plugin.
57 * @return \Drupal\media\MediaSourceInterface
60 public function getSource();
63 * Sets whether new revisions should be created by default.
65 * @param bool $new_revision
66 * TRUE if media items of this type should create new revisions by default.
70 public function setNewRevision($new_revision);
73 * Returns the metadata field map.
75 * Field mapping allows site builders to map media item-related metadata to
76 * entity fields. This information will be used when saving a given media item
77 * and if metadata values will be available they are going to be automatically
78 * copied to the corresponding entity fields.
81 * Field mapping array provided by media source with metadata attribute
82 * names as keys and entity field names as values.
84 public function getFieldMap();
87 * Sets the metadata field map.
90 * Field mapping array with metadata attribute names as keys and entity
91 * field names as values.
95 public function setFieldMap(array $map);