You are here

public function DownloadFileAccess::access in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_export/src/Access/DownloadFileAccess.php \Drupal\bibcite_export\Access\DownloadFileAccess::access()

Check if user has a permission and own the file.

Parameters

\Drupal\Core\Session\AccountInterface $account: Account to check access for.

\Drupal\file\FileInterface $file: File to grant access for.

Return value

\Drupal\Core\Access\AccessResult Access checking result.

1 string reference to 'DownloadFileAccess::access'
bibcite_export.routing.yml in modules/bibcite_export/bibcite_export.routing.yml
modules/bibcite_export/bibcite_export.routing.yml

File

modules/bibcite_export/src/Access/DownloadFileAccess.php, line 26

Class

DownloadFileAccess
Access check for file, generate by "Export all" form.

Namespace

Drupal\bibcite_export\Access

Code

public function access(AccountInterface $account, FileInterface $file) {
  return AccessResult::allowedIf(($account
    ->hasPermission('administer bibcite') || $account
    ->hasPermission('access bibcite export')) && $file
    ->getOwnerId() == $account
    ->id());
}