function views_data_export_file_access in Views data export 8
Implements hook_ENTITY_TYPE_access().
File
- ./
views_data_export.module, line 59 - The views data export allowing exporting data from views displays.
Code
function views_data_export_file_access(EntityInterface $entity, $operation, AccountInterface $account) {
/* @var $entity EntityInterface */
if ($operation == 'download') {
// Grant access to download the generate export if it was generated by the
// current user.
$pattern = '/\\/\\/views_data_export\\/(?<uid>\\d+)-\\d+-.+\\.csv$/';
preg_match($pattern, $entity
->getFileUri(), $matches);
if (isset($matches['uid']) && $matches['uid'] == $account
->id()) {
return AccessResult::allowed();
}
}
}