Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295807

Separate MIME type mapping from ExtensionMimeTypeGuesser

$
0
0

Problem/Motivation

With #1921558: Convert file_get_mimetype() to use Symfony MimeTypeGuessers, the function file_mimetype_mapping() was removed. The mapping was placed as a protected property of the ExtensionMimeTypeGuesser class, as its main purpose was for the guesser to use it. But there are cases when the mapping, or just the list of MIME types, should be used in itself, outside the context of guessing. For instance, a form in the File entity module should present known MIME types for the user.

Proposed resolution

Move the default mapping to a new service and class, Drupal\Core\File\MimeType\MimeTypeMapper.

Introduce an alterMapping() method which invokes the file_mimetype_mapping alter hook upon service instantiation to allow modules to play with MIME type<->extension mapping.

Introduce getter/setter methods.

Add tests.

Remaining tasks

Commit

User interface changes

None

API changes

A new service file.mime_type.mapper.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue categoryBug because functionality in previous version is now missing
Issue priorityMajor because it is a small regression. In D7 one could access the mapping out of the context of guessing, and could eg get a list of all known mimetypes . After #1921558: Convert file_get_mimetype() to use Symfony MimeTypeGuessers its impossible without extending the class, because the mapping is a protected property
DisruptionIt changes hook_file_mimetype_mapping_alter's signature, but this hook is not used much (i saw somewhere that only one contrib module used it in d7)

Viewing all articles
Browse latest Browse all 295807

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>