You are here

protected function VideoEmbedField::getVideoUrl in Video Embed Field 8.2

Get the video URL from a media entity.

Parameters

\Drupal\media\MediaInterface $media: The media entity.

Return value

string|bool A video URL or FALSE on failure.

1 call to VideoEmbedField::getVideoUrl()
VideoEmbedField::getMetadata in modules/video_embed_media/src/Plugin/media/Source/VideoEmbedField.php
Gets the value for a metadata attribute for a given media item.

File

modules/video_embed_media/src/Plugin/media/Source/VideoEmbedField.php, line 164

Class

VideoEmbedField
Provides media source plugin for video embed field.

Namespace

Drupal\video_embed_media\Plugin\media\Source

Code

protected function getVideoUrl(MediaInterface $media) {
  $media_type = $this->entityTypeManager
    ->getStorage('media_type')
    ->load($media
    ->bundle());
  $source_field = $this
    ->getSourceFieldDefinition($media_type);
  $field_name = $source_field
    ->getName();
  $video_url = $media->{$field_name}->value;
  return !empty($video_url) ? $video_url : FALSE;
}