You are here

class FileReplaceAccessCheck in File Replace (D8) 8

Determines access to replacing a file.

Hierarchy

Expanded class hierarchy of FileReplaceAccessCheck

1 string reference to 'FileReplaceAccessCheck'
file_replace.services.yml in ./file_replace.services.yml
file_replace.services.yml
1 service uses FileReplaceAccessCheck
access_check.file_replace.editable_usages in ./file_replace.services.yml
Drupal\file_replace\Access\FileReplaceAccessCheck

File

src/Access/FileReplaceAccessCheck.php, line 14

Namespace

Drupal\file_replace\Access
View source
class FileReplaceAccessCheck implements AccessInterface {

  /**
   * The file usage service.
   *
   * @var \Drupal\file\FileUsage\FileUsageInterface
   */
  protected $fileUsage;

  /**
   * Constructs a EntityCreateAccessCheck object.
   *
   * @param \Drupal\file\FileUsage\FileUsageInterface $file_usage
   *   The file usage service.
   */
  public function __construct(FileUsageInterface $file_usage) {
    $this->fileUsage = $file_usage;
  }

  /**
   * Checks access for replacing a file.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   * @param \Drupal\file\FileInterface $file
   *   The file to check access for.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account, FileInterface $file) {
    return AccessResult::allowedIf($account
      ->hasPermission('replace files') && $file
      ->isPermanent());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileReplaceAccessCheck::$fileUsage protected property The file usage service.
FileReplaceAccessCheck::access public function Checks access for replacing a file.
FileReplaceAccessCheck::__construct public function Constructs a EntityCreateAccessCheck object.