You are here

function hook_file_type in File Entity (fieldable files) 8.2

Same name and namespace in other branches
  1. 7.3 file_entity.api.php \hook_file_type()
  2. 7.2 file_entity.api.php \hook_file_type()

Decides which file type (bundle) should be assigned to a file entity.

Parameters

object $file: File object.

Return value

array Array of file type machine names that can be assigned to a given file type. If there are more proposed file types the one, that was returned the first, wil be chosen. This can be, however, changed in alter hook.

See also

hook_file_type_alter()

1 function implements hook_file_type()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

file_entity_file_type in ./file_entity.file.inc
Implements hook_file_type().
2 invocations of hook_file_type()
FileAddForm::getCandidateFileTypes in src/Form/FileAddForm.php
Get the candidate filetypes for a given file.
FileEntity::determineType in src/Entity/FileEntity.php
Determines file type for a given file.

File

./file_entity.api.php, line 64
Hooks provided by the File Entity module.

Code

function hook_file_type($file) {

  // Assign all files uploaded by anonymous users to a special file type.
  if (\Drupal::currentUser()
    ->isAnonymous()) {
    return array(
      'untrusted_files',
    );
  }
}