You are here

protected function MediaUploader::getRandomFileName in Gutenberg 8

Generate random file name.

Parameters

\Drupal\gutenberg\string $extension: (optional) File extension.

Return value

string The file name.

1 call to MediaUploader::getRandomFileName()
MediaUploader::upload in src/MediaUploader.php
Upload media to the filesystem.

File

src/MediaUploader.php, line 71

Class

MediaUploader
Upload files from Gutenberg editor upload method.

Namespace

Drupal\gutenberg

Code

protected function getRandomFileName(string $extension = '') {
  $name = (new Random())
    ->name(50, TRUE);
  return $extension ? sprintf('%s.%s', $name, $extension) : $name;
}