function file_test_file_download

Same name and namespace in other branches
  1. 7.x modules/simpletest/tests/file_test.module \file_test_file_download()
  2. 9 core/modules/file/tests/file_test/file_test.module \file_test_file_download()
  3. 8.9.x core/modules/file/tests/file_test/file_test.module \file_test_file_download()

Implements hook_file_download().

File

core/modules/file/tests/file_test/file_test.module, line 147

Code

function file_test_file_download($uri) {
  if (\Drupal::state()->get('file_test.allow_all', FALSE)) {
    $files = \Drupal::entityTypeManager()->getStorage('file')
      ->loadByProperties([
      'uri' => $uri,
    ]);
    $file = reset($files);
    return file_get_content_headers($file);
  }
  _file_test_log_call('download', [
    $uri,
  ]);
  return _file_test_get_return('download');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.