You are here

public function AudioStream::getMetadata in Media entity audio 8.3

Gets the value for a metadata attribute for a given media item.

Parameters

\Drupal\media\MediaInterface $media: A media item.

string $attribute_name: Name of the attribute to fetch.

Return value

mixed|null Metadata attribute value or NULL if unavailable.

Overrides MediaSourceBase::getMetadata

File

src/Plugin/media/Source/AudioStream.php, line 26

Class

AudioStream
Provides media type plugin for Audio.

Namespace

Drupal\media_entity_audio\Plugin\media\Source

Code

public function getMetadata(MediaInterface $media, $attribute_name) {
  switch ($attribute_name) {
    case 'default_name':
      return basename($media
        ->get($this->configuration['source_field'])->uri);
  }
  return parent::getMetadata($media, $attribute_name);
}