public function Document::getDefaultName in Media entity document 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/ Document.php, line 87  
Class
- Document
 - Provides media type plugin for Document.
 
Namespace
Drupal\media_entity_document\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);
}