private function AudioFieldPluginBase::getAudioSource in AudioField 8
Get source URL from an audiofield entity.
Parameters
\Drupal\file\Plugin\Field\FieldType\FileItem|\Drupal\link\Plugin\Field\FieldType\LinkItem $item: Item for which we are determining source.
Return value
\Drupal\Core\Url|string The source URL of an entity.
3 calls to AudioFieldPluginBase::getAudioSource()
- AudioFieldPluginBase::createDownloadList in src/
AudioFieldPluginBase.php - Used to render list of downloads as an item list.
- AudioFieldPluginBase::getAudioRenderInfo in src/
AudioFieldPluginBase.php - Get required rendering information from an entity.
- AudioFieldPluginBase::validateEntityAgainstPlayer in src/
AudioFieldPluginBase.php - Validate that this entity will work with this player.
File
- src/
AudioFieldPluginBase.php, line 458
Class
- AudioFieldPluginBase
- Base class for audiofield plugins. Includes global functions.
Namespace
Drupal\audiofieldCode
private function getAudioSource($item) {
if ($this
->getClassType($item) == 'FileItem') {
// Load the associated file.
$file = $this
->loadFileFromItem($item);
// Get the file URL.
return Url::fromUri(file_create_url($file
->getFileUri()));
}
elseif ($this
->getClassType($item) == 'LinkItem') {
// Get the file URL.
return $item
->getUrl();
}
return '';
}