comparison core/modules/media/src/MediaSourceInterface.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children af1871eacc83
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
2 2
3 namespace Drupal\media; 3 namespace Drupal\media;
4 4
5 use Drupal\Component\Plugin\ConfigurablePluginInterface; 5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface; 6 use Drupal\Component\Plugin\PluginInspectionInterface;
7 use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
8 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
7 use Drupal\Core\Plugin\PluginFormInterface; 9 use Drupal\Core\Plugin\PluginFormInterface;
8 10
9 /** 11 /**
10 * Defines the interface for media source plugins. 12 * Defines the interface for media source plugins.
11 * 13 *
21 * Examples of possible sources are: 23 * Examples of possible sources are:
22 * - File: handles local files, 24 * - File: handles local files,
23 * - Image: handles local images, 25 * - Image: handles local images,
24 * - oEmbed: handles resources that are exposed through the oEmbed standard, 26 * - oEmbed: handles resources that are exposed through the oEmbed standard,
25 * - YouTube: handles YouTube videos, 27 * - YouTube: handles YouTube videos,
26 * - SoundCould: handles SoundCloud audio, 28 * - SoundCloud: handles SoundCloud audio,
27 * - Instagram: handles Instagram posts, 29 * - Instagram: handles Instagram posts,
28 * - Twitter: handles tweets, 30 * - Twitter: handles tweets,
29 * - ... 31 * - ...
30 * 32 *
31 * Their responsibilities are: 33 * Their responsibilities are:
137 * The unsaved field definition. The field storage definition, if new, 139 * The unsaved field definition. The field storage definition, if new,
138 * should also be unsaved. 140 * should also be unsaved.
139 */ 141 */
140 public function createSourceField(MediaTypeInterface $type); 142 public function createSourceField(MediaTypeInterface $type);
141 143
144 /**
145 * Prepares the media type fields for this source in the view display.
146 *
147 * This method should normally call
148 * \Drupal\Core\Entity\Display\EntityDisplayInterface::setComponent() or
149 * \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent() to
150 * configure the media type fields in the view display.
151 *
152 * @param \Drupal\media\MediaTypeInterface $type
153 * The media type which is using this source.
154 * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
155 * The display which should be prepared.
156 *
157 * @see \Drupal\Core\Entity\Display\EntityDisplayInterface::setComponent()
158 * @see \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent()
159 */
160 public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display);
161
162 /**
163 * Prepares the media type fields for this source in the form display.
164 *
165 * This method should normally call
166 * \Drupal\Core\Entity\Display\EntityDisplayInterface::setComponent() or
167 * \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent() to
168 * configure the media type fields in the form display.
169 *
170 * @param \Drupal\media\MediaTypeInterface $type
171 * The media type which is using this source.
172 * @param \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display
173 * The display which should be prepared.
174 *
175 * @see \Drupal\Core\Entity\Display\EntityDisplayInterface::setComponent()
176 * @see \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent()
177 */
178 public function prepareFormDisplay(MediaTypeInterface $type, EntityFormDisplayInterface $display);
179
180 /**
181 * Get the primary value stored in the source field.
182 *
183 * @param MediaInterface $media
184 * A media item.
185 *
186 * @return mixed
187 * The source value.
188 *
189 * @throws \RuntimeException
190 * If the source field for the media source is not defined.
191 */
192 public function getSourceFieldValue(MediaInterface $media);
193
142 } 194 }