You are here

protected function Soundcloud::getMediaUrl in Media entity Soundcloud 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/media/Source/Soundcloud.php \Drupal\media_entity_soundcloud\Plugin\media\Source\Soundcloud::getMediaUrl()

Returns the track id from the source_url_field.

Parameters

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

Return value

string|bool The track if from the source_url_field if found. False otherwise.

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

File

src/Plugin/media/Source/Soundcloud.php, line 163

Class

Soundcloud
Soundcloud entity media source.

Namespace

Drupal\media_entity_soundcloud\Plugin\media\Source

Code

protected function getMediaUrl(MediaInterface $media) {
  $source_field = $this
    ->getSourceFieldDefinition($media->bundle->entity);
  $field_name = $source_field
    ->getName();
  if ($media
    ->hasField($field_name)) {
    $property_name = $source_field
      ->getFieldStorageDefinition()
      ->getMainPropertyName();
    return $media->{$field_name}->{$property_name};
  }
  return FALSE;
}