7e3b9fde84be2a1fc379c5911a54affb8a4eea27
[yaffs-website] / web / core / modules / media / src / MediaTypeInterface.php
1 <?php
2
3 namespace Drupal\media;
4
5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
6 use Drupal\Core\Entity\EntityDescriptionInterface;
7 use Drupal\Core\Entity\RevisionableEntityBundleInterface;
8
9 /**
10  * Provides an interface defining a media type entity.
11  *
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.
15  *
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.
20  *
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
25  *   different things.
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
29  *   different.
30  *
31  * @see \Drupal\media\MediaSourceInterface
32  */
33 interface MediaTypeInterface extends ConfigEntityInterface, EntityDescriptionInterface, RevisionableEntityBundleInterface {
34
35   /**
36    * Returns whether thumbnail downloads are queued.
37    *
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
40    * background.
41    *
42    * @return bool
43    *   TRUE if thumbnails are queued for download later, FALSE if they should be
44    *   downloaded now.
45    */
46   public function thumbnailDownloadsAreQueued();
47
48   /**
49    * Sets a flag to indicate that thumbnails should be downloaded via a queue.
50    *
51    * @param bool $queue_thumbnail_downloads
52    *   The queue downloads flag.
53    *
54    * @return $this
55    */
56   public function setQueueThumbnailDownloadsStatus($queue_thumbnail_downloads);
57
58   /**
59    * Returns the media source plugin.
60    *
61    * @return \Drupal\media\MediaSourceInterface
62    *   The media source.
63    */
64   public function getSource();
65
66   /**
67    * Sets whether new revisions should be created by default.
68    *
69    * @param bool $new_revision
70    *   TRUE if media items of this type should create new revisions by default.
71    *
72    * @return $this
73    */
74   public function setNewRevision($new_revision);
75
76   /**
77    * Returns the metadata field map.
78    *
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.
83    *
84    * @return array
85    *   Field mapping array provided by media source with metadata attribute
86    *   names as keys and entity field names as values.
87    */
88   public function getFieldMap();
89
90   /**
91    * Sets the metadata field map.
92    *
93    * @param array $map
94    *   Field mapping array with metadata attribute names as keys and entity
95    *   field names as values.
96    *
97    * @return $this
98    */
99   public function setFieldMap(array $map);
100
101 }