You are here

interface MediaTypeInterface in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/MediaTypeInterface.php \Drupal\media\MediaTypeInterface

Provides an interface defining a media type entity.

Media types are bundles for media items. They are used to group media with the same semantics. Media types are not about where media comes from. They are about the semantics that media has in the context of a given Drupal site.

Media sources, on the other hand, are aware where media comes from and know how to represent and handle it in Drupal's context. They are aware of the low level details, while the media types don't care about them at all. That said, media types can not exist without media sources.

Consider the following examples:

  • oEmbed media source which can represent any oEmbed resource. Media types that could be used with this source are "Videos", "Charts", "Music", etc. All of them are retrieved using the same protocol, but they represent very different things.
  • Media sources that represent files could be used with media types like "Invoices", "Subtitles", "Meeting notes", etc. They are all files stored on some kind of storage, but their meaning and uses in a Drupal site are different.

Hierarchy

Expanded class hierarchy of MediaTypeInterface

All classes that implement MediaTypeInterface

See also

\Drupal\media\MediaSourceInterface

14 files declare their use of MediaTypeInterface
AddFormBase.php in core/modules/media_library/src/Form/AddFormBase.php
AudioFile.php in core/modules/media/src/Plugin/media/Source/AudioFile.php
File.php in core/modules/media/src/Plugin/media/Source/File.php
FileUploadForm.php in core/modules/media_library/src/Form/FileUploadForm.php
Image.php in core/modules/media/src/Plugin/media/Source/Image.php

... See full list

File

core/modules/media/src/MediaTypeInterface.php, line 33

Namespace

Drupal\media
View source
interface MediaTypeInterface extends ConfigEntityInterface, EntityDescriptionInterface, RevisionableEntityBundleInterface {

  /**
   * Returns whether thumbnail downloads are queued.
   *
   * When using remote media sources, the thumbnail generation could be a slow
   * process. Using a queue allows for this process to be handled in the
   * background.
   *
   * @return bool
   *   TRUE if thumbnails are queued for download later, FALSE if they should be
   *   downloaded now.
   */
  public function thumbnailDownloadsAreQueued();

  /**
   * Sets a flag to indicate that thumbnails should be downloaded via a queue.
   *
   * @param bool $queue_thumbnail_downloads
   *   The queue downloads flag.
   *
   * @return $this
   */
  public function setQueueThumbnailDownloadsStatus($queue_thumbnail_downloads);

  /**
   * Returns the media source plugin.
   *
   * @return \Drupal\media\MediaSourceInterface
   *   The media source.
   */
  public function getSource();

  /**
   * Sets whether new revisions should be created by default.
   *
   * @param bool $new_revision
   *   TRUE if media items of this type should create new revisions by default.
   *
   * @return $this
   */
  public function setNewRevision($new_revision);

  /**
   * Returns the metadata field map.
   *
   * Field mapping allows site builders to map media item-related metadata to
   * entity fields. This information will be used when saving a given media item
   * and if metadata values will be available they are going to be automatically
   * copied to the corresponding entity fields.
   *
   * @return array
   *   Field mapping array provided by media source with metadata attribute
   *   names as keys and entity field names as values.
   */
  public function getFieldMap();

  /**
   * Sets the metadata field map.
   *
   * @param array $map
   *   Field mapping array with metadata attribute names as keys and entity
   *   field names as values.
   *
   * @return $this
   */
  public function setFieldMap(array $map);

}

Members

Namesort descending Modifiers Type Description Overrides
AccessibleInterface::access public function Checks data value access. 9
CacheableDependencyInterface::getCacheContexts public function The cache contexts associated with this object. 34
CacheableDependencyInterface::getCacheMaxAge public function The maximum age for which this object may be cached. 34
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. 27
ConfigEntityInterface::calculateDependencies public function Calculates dependencies and stores them in the dependency property. 2
ConfigEntityInterface::disable public function Disables the configuration entity. 2
ConfigEntityInterface::enable public function Enables the configuration entity. 2
ConfigEntityInterface::get public function Returns the value of a property. 2
ConfigEntityInterface::getDependencies public function Gets the configuration dependencies. 2
ConfigEntityInterface::hasTrustedData public function Gets whether on not the data is trusted. 2
ConfigEntityInterface::isInstallable public function Checks whether this entity is installable. 2
ConfigEntityInterface::isUninstalling public function Returns whether this entity is being changed during the uninstall process. 2
ConfigEntityInterface::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. 2
ConfigEntityInterface::set public function Sets the value of a property. 2
ConfigEntityInterface::setStatus public function Sets the status of the configuration entity. 2
ConfigEntityInterface::status public function Returns whether the configuration entity is enabled. 2
ConfigEntityInterface::trustData public function Sets that the data should be trusted. 2
EntityDescriptionInterface::getDescription public function Gets the entity description. 3
EntityDescriptionInterface::setDescription public function Sets the entity description. 3
EntityInterface::bundle public function Gets the bundle of the entity. 2
EntityInterface::create public static function Constructs a new entity object, without permanently saving it. 2
EntityInterface::createDuplicate public function Creates a duplicate of the entity. 2
EntityInterface::delete public function Deletes an entity permanently. 2
EntityInterface::enforceIsNew public function Enforces an entity to be new. 2
EntityInterface::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. 2
EntityInterface::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. 2
EntityInterface::getConfigDependencyName public function Gets the configuration dependency name. 2
EntityInterface::getConfigTarget public function Gets the configuration target identifier for the entity. 2
EntityInterface::getEntityType public function Gets the entity type definition. 2
EntityInterface::getEntityTypeId public function Gets the ID of the type of the entity. 2
EntityInterface::getOriginalId public function Gets the original ID. 2
EntityInterface::getTypedData public function Gets a typed data object for this entity object. 2
EntityInterface::hasLinkTemplate public function Indicates if a link template exists for a given key. 2
EntityInterface::id public function Gets the identifier. 2
EntityInterface::isNew public function Determines whether the entity is new. 2
EntityInterface::label public function Gets the label of the entity. 2
EntityInterface::language public function Gets the language of the entity. 2
EntityInterface::load public static function Loads an entity. 2
EntityInterface::loadMultiple public static function Loads one or more entities. 2
EntityInterface::postCreate public function Acts on a created entity before hooks are invoked. 2
EntityInterface::postDelete public static function Acts on deleted entities before the delete hook is invoked. 2
EntityInterface::postLoad public static function Acts on loaded entities. 3
EntityInterface::postSave public function Acts on a saved entity before the insert or update hook is invoked. 2
EntityInterface::preCreate public static function Changes the values of an entity before it is created. 2
EntityInterface::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. 2
EntityInterface::preSave public function Acts on an entity before the presave hook is invoked. 2
EntityInterface::referencedEntities public function Gets a list of entities referenced by this entity. 2
EntityInterface::save public function Saves an entity permanently. 2
EntityInterface::setOriginalId public function Sets the original ID. 2
EntityInterface::toArray public function Gets an array of all property values. 3
EntityInterface::toLink public function Generates the HTML for a link to this entity. 2
EntityInterface::toUrl public function Gets the URL object for the entity. 2
EntityInterface::uriRelationships public function Gets a list of URI relationships supported by this entity. 2
EntityInterface::uuid public function Gets the entity UUID (Universally Unique Identifier). 2
MediaTypeInterface::getFieldMap public function Returns the metadata field map. 1
MediaTypeInterface::getSource public function Returns the media source plugin. 1
MediaTypeInterface::setFieldMap public function Sets the metadata field map. 1
MediaTypeInterface::setNewRevision public function Sets whether new revisions should be created by default. 1
MediaTypeInterface::setQueueThumbnailDownloadsStatus public function Sets a flag to indicate that thumbnails should be downloaded via a queue. 1
MediaTypeInterface::thumbnailDownloadsAreQueued public function Returns whether thumbnail downloads are queued. 1
RefinableCacheableDependencyInterface::addCacheableDependency public function Adds a dependency on an object: merges its cacheability metadata. 1
RefinableCacheableDependencyInterface::addCacheContexts public function Adds cache contexts. 1
RefinableCacheableDependencyInterface::addCacheTags public function Adds cache tags. 1
RefinableCacheableDependencyInterface::mergeCacheMaxAge public function Merges the maximum age (in seconds) with the existing maximum age. 1
RevisionableEntityBundleInterface::shouldCreateNewRevision public function Gets whether a new revision should be created by default. 3
SynchronizableInterface::isSyncing public function Returns whether this entity is being changed as part of a synchronization. 1
SynchronizableInterface::setSyncing public function Sets the status of the synchronization flag. 1
ThirdPartySettingsInterface::getThirdPartyProviders public function Gets the list of third parties that store information. 5
ThirdPartySettingsInterface::getThirdPartySetting public function Gets the value of a third-party setting. 5
ThirdPartySettingsInterface::getThirdPartySettings public function Gets all third-party settings of a given module. 5
ThirdPartySettingsInterface::setThirdPartySetting public function Sets the value of a third-party setting. 5
ThirdPartySettingsInterface::unsetThirdPartySetting public function Unsets a third-party setting. 5