You are here

public function MediaService::loadMediaData in Gutenberg 8

Same name and namespace in other branches
  1. 8.2 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 298

Class

MediaService
The media service class.

Namespace

Drupal\gutenberg\Service

Code

public function loadMediaData(MediaInterface $media) {
  $file_entity_id = $media
    ->getSource()
    ->getSourceFieldValue($media);
  $file_entity = $this->entityTypeManager
    ->getStorage('file')
    ->load($file_entity_id);
  return $this->entityDataProviderManager
    ->getData('file', $file_entity);
}