Commit d29adc88 authored by alexpott's avatar alexpott

Issue #2297947 by amitgoyal, andrewmacpherson: Clean up API docs for...

Issue #2297947 by amitgoyal, andrewmacpherson: Clean up API docs for hook_file_mimetype_mapping_alter().
parent dc7a5422
...@@ -1297,16 +1297,19 @@ function file_upload_max_size() { ...@@ -1297,16 +1297,19 @@ function file_upload_max_size() {
* @param $mapping * @param $mapping
* An optional map of extensions to their mimetypes, in the form: * An optional map of extensions to their mimetypes, in the form:
* - 'mimetypes': a list of mimetypes, keyed by an identifier, * - 'mimetypes': a list of mimetypes, keyed by an identifier,
* - 'extensions': the mapping itself, an associative array in which * - 'extensions': the mapping itself, an associative array in which the key
* the key is the extension (lowercase) and the value is the mimetype * is the extension (lowercase) and the value is the mimetype identifier.
* identifier. If $mapping is NULL file_mimetype_mapping() is called.
* *
* @return * @return
* The internet media type registered for the extension or * The internet media type registered for the extension or
* application/octet-stream for unknown extensions. * application/octet-stream for unknown extensions.
* *
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. Calls are
* Use \Drupal::service('file.mime_type.guesser')->guess($uri). * passed on to a new file.mime_type.guesser service, and the $mapping
* parameter is ignored. Use
* \Drupal::service('file.mime_type.guesser')->guess($uri).
*
* @see \Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser::guess()
*/ */
function file_get_mimetype($uri, $mapping = NULL) { function file_get_mimetype($uri, $mapping = NULL) {
return \Drupal::service('file.mime_type.guesser')->guess($uri); return \Drupal::service('file.mime_type.guesser')->guess($uri);
......
...@@ -2304,16 +2304,17 @@ function hook_install_tasks_alter(&$tasks, $install_state) { ...@@ -2304,16 +2304,17 @@ function hook_install_tasks_alter(&$tasks, $install_state) {
/** /**
* Alter MIME type mappings used to determine MIME type from a file extension. * Alter MIME type mappings used to determine MIME type from a file extension.
* *
* This hook is run when file_mimetype_mapping() is called. It is used to * Invoked by \Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser::guess(). It
* allow modules to add to or modify the default mapping from * is used to allow modules to add to or modify the default mapping from
* file_default_mimetype_mapping(). * \Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser::$defaultMapping.
* *
* @param $mapping * @param $mapping
* An array of mimetypes correlated to the extensions that relate to them. * An array of mimetypes correlated to the extensions that relate to them.
* The array has 'mimetypes' and 'extensions' elements, each of which is an * The array has 'mimetypes' and 'extensions' elements, each of which is an
* array. * array.
* *
* @see file_default_mimetype_mapping() * @see \Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser::guess()
* @see \Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser::$defaultMapping
*/ */
function hook_file_mimetype_mapping_alter(&$mapping) { function hook_file_mimetype_mapping_alter(&$mapping) {
// Add new MIME type 'drupal/info'. // Add new MIME type 'drupal/info'.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment