class FileExtensionGuesser in Gutenberg 8
Same name and namespace in other branches
- 8.2 src/FileExtensionGuesser.php \Drupal\gutenberg\FileExtensionGuesser
Guesses all possible extensions .
@package Drupal\gutenberg
Hierarchy
- class \Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser implements \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface
- class \Drupal\gutenberg\FileExtensionGuesser implements FileExtensionGuesserInterface
Expanded class hierarchy of FileExtensionGuesser
1 string reference to 'FileExtensionGuesser'
1 service uses FileExtensionGuesser
File
- src/
FileExtensionGuesser.php, line 12
Namespace
Drupal\gutenbergView source
class FileExtensionGuesser extends ExtensionMimeTypeGuesser implements FileExtensionGuesserInterface {
/**
* {@inheritDoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExtensionMimeTypeGuesser:: |
protected | property | Default MIME extension mapping. | |
ExtensionMimeTypeGuesser:: |
protected | property | The MIME types mapping array after going through the module handler. | |
ExtensionMimeTypeGuesser:: |
protected | property | The module handler. | |
ExtensionMimeTypeGuesser:: |
public | function | Guesses the mime type of the file with the given path. | |
ExtensionMimeTypeGuesser:: |
public | function | Sets the mimetypes/extension mapping to use when guessing mimetype. | |
ExtensionMimeTypeGuesser:: |
public | function | Constructs a new ExtensionMimeTypeGuesser. | |
FileExtensionGuesser:: |
public | function |
Guesses all possible file extensions by general mime type. Overrides FileExtensionGuesserInterface:: |