Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

The arguments to these functions have changed to adopt related 8.x changes, make them more useful in general and in case of the alter hook, fix the problem that the last argument is not actually passed to hook implementations.

7.x

function node_file_download_access($field, $entity_type, $entity) {
  if ($entity_type == 'node') {
    return node_access('view', $entity);
  } 
}

function yourmodule_file_download_access_alter(&$grants, $field, $entity_type, $entity) {
  
}

8.x

function node_file_download_access($field, EntityInterface $entity, File $file) {
  if ($entity->entityType() == 'node') {
    return node_access('view', $entity);
  } 
}

function yourmodule_file_download_access_alter(&$grants, $context) {

}

$context is an associative array containing the following key-value pairs:

  • entity: The entity to which the field item is referenced.
  • field: The field info of the field the field_item belongs to.
  • file: The file entity that is being requested.