public function MediaService::loadMediaData in Gutenberg 8.2
Same name and namespace in other branches
- 8 src/Service/MediaService.php \Drupal\gutenberg\Service\MediaService::loadMediaData()
Load media entity data.
Parameters
\Drupal\media\MediaInterface $media: Media entity instance.
Return value
mixed The file entity data for the specified media.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
Service/ MediaService.php, line 313
Class
- MediaService
- The media service class.
Namespace
Drupal\gutenberg\ServiceCode
public function loadMediaData(MediaInterface $media) {
$file_entity_id = $media
->getSource()
->getSourceFieldValue($media);
$file_entity = $this->entityTypeManager
->getStorage('file')
->load($file_entity_id);
$file_data = $this->entityDataProviderManager
->getData('file', $file_entity);
$file_data['media_entity'] = [
'bundle' => $media
->bundle(),
'id' => $media
->id(),
'label' => $media
->label(),
];
return $file_data;
}