public function Video::getDefaultName in Media entity video 8
Provide a default name for the media.
Plugins defining media bundles are suggested to override this method and provide a default name, to be used when there is no user-defined label available.
Parameters
\Drupal\media_entity\MediaInterface $media: The media object.
Return value
string The string that should be used as default media name.
Overrides MediaTypeBase::getDefaultName
File
- src/
Plugin/ MediaEntity/ Type/ Video.php, line 90
Class
- Video
- Provides media type plugin for Video.
Namespace
Drupal\media_entity_video\Plugin\MediaEntity\TypeCode
public function getDefaultName(MediaInterface $media) {
// The default name will be the filename of the source_field, if present.
$source_field = $this->configuration['source_field'];
/** @var \Drupal\file\FileInterface $file */
if (!empty($source_field) && ($file = $media->{$source_field}->entity)) {
return $file
->getFilename();
}
return parent::getDefaultName($media);
}