You are here

public function FileExtensionGuesser::guessByGeneralMimeType in Gutenberg 8.2

Same name and namespace in other branches
  1. 8 src/FileExtensionGuesser.php \Drupal\gutenberg\FileExtensionGuesser::guessByGeneralMimeType()

Guesses all possible file extensions by general mime type.

Parameters

string $general_mime_type: General mime type (image, video, audio, ...).

Return value

array The mime types.

Overrides FileExtensionGuesserInterface::guessByGeneralMimeType

File

src/FileExtensionGuesser.php, line 17

Class

FileExtensionGuesser
Guesses all possible extensions .

Namespace

Drupal\gutenberg

Code

public function guessByGeneralMimeType(string $general_mime_type) {
  $mime_types = array_filter($this->defaultMapping['mimetypes'], function ($mime_type) use ($general_mime_type) {
    $pieces = explode('/', $mime_type);
    return $pieces[0] === $general_mime_type;
  });
  $mime_type_ids = array_keys($mime_types);
  $filtered_extensions = array_filter($this->defaultMapping['extensions'], function ($mime_type_id) use ($mime_type_ids) {
    return in_array($mime_type_id, $mime_type_ids);
  });
  return array_keys($filtered_extensions);
}