diff --git a/modules/file/file.api.php b/modules/file/file.api.php index 72aae40..f2e650e 100644 --- a/modules/file/file.api.php +++ b/modules/file/file.api.php @@ -47,10 +47,12 @@ function hook_file_download_access($file_item, $entity_type, $entity) { * values are Boolean grant responses for each module. * @param array $file_item * The array of information about the file to alter access for. - * @param $entity_type - * The type of $entity; for example, 'node' or 'user'. - * @param $entity - * The $entity to which $file is referenced. + * @param array $context + * An associative array containing the following key-value pairs, matching the + * arguments received by hook_file_download_access(): + * - "entity_type": The type of $context['entity']; for example, 'node' or + * 'user'. + * - "entity": The $entity to which $file is referenced. * * @return * An array of grants, keyed by module name, each with a Boolean grant value. @@ -58,7 +60,7 @@ function hook_file_download_access($file_item, $entity_type, $entity) { * module's value in addition to other grants or to overwrite the values set * by other modules. */ -function hook_file_download_access_alter(&$grants, $file_item, $entity_type, $entity) { +function hook_file_download_access_alter(&$grants, $file_item, array $context) { // For our example module, we always enforce the rules set by node module. if (isset($grants['node'])) { $grants = array('node' => $grants['node']); diff --git a/modules/file/file.module b/modules/file/file.module index ebf80e9..6174bf0 100644 --- a/modules/file/file.module +++ b/modules/file/file.module @@ -197,7 +197,11 @@ function file_file_download($uri, $field_type = 'file') { $grants = array_merge($grants, array($module => module_invoke($module, 'file_download_access', $field_item, $entity_type, $entity))); } // Allow other modules to alter the returned grants/denies. - drupal_alter('file_download_access', $grants, $field_item, $entity_type, $entity); + $context = array( + 'entity_type' => $entity_type, + 'entity' => $entity, + ); + drupal_alter('file_download_access', $grants, $field_item, array $context); if (in_array(TRUE, $grants)) { // If TRUE is returned, access is granted and no further checks are