You are here

class DownloadFileAccess 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 for file, generate by "Export all" form.

Hierarchy

Expanded class hierarchy of DownloadFileAccess

File

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

Namespace

Drupal\bibcite_export\Access
View source
class DownloadFileAccess implements AccessInterface {

  /**
   * Check if user has a permission and own the file.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Account to check access for.
   * @param \Drupal\file\FileInterface $file
   *   File to grant access for.
   *
   * @return \Drupal\Core\Access\AccessResult
   *   Access checking result.
   */
  public function access(AccountInterface $account, FileInterface $file) {
    return AccessResult::allowedIf(($account
      ->hasPermission('administer bibcite') || $account
      ->hasPermission('access bibcite export')) && $file
      ->getOwnerId() == $account
      ->id());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DownloadFileAccess::access public function Check if user has a permission and own the file.