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.
38 * When using remote media sources, the thumbnail generation could be a slow
39 * process. Using a queue allows for this process to be handled in the
43 * TRUE if thumbnails are queued for download later, FALSE if they should be
46 public function thumbnailDownloadsAreQueued();
49 * Sets a flag to indicate that thumbnails should be downloaded via a queue.
51 * @param bool $queue_thumbnail_downloads
52 * The queue downloads flag.
56 public function setQueueThumbnailDownloadsStatus($queue_thumbnail_downloads);
59 * Returns the media source plugin.
61 * @return \Drupal\media\MediaSourceInterface
64 public function getSource();
67 * Sets whether new revisions should be created by default.
69 * @param bool $new_revision
70 * TRUE if media items of this type should create new revisions by default.
74 public function setNewRevision($new_revision);
77 * Returns the metadata field map.
79 * Field mapping allows site builders to map media item-related metadata to
80 * entity fields. This information will be used when saving a given media item
81 * and if metadata values will be available they are going to be automatically
82 * copied to the corresponding entity fields.
85 * Field mapping array provided by media source with metadata attribute
86 * names as keys and entity field names as values.
88 public function getFieldMap();
91 * Sets the metadata field map.
94 * Field mapping array with metadata attribute names as keys and entity
95 * field names as values.
99 public function setFieldMap(array $map);