You are here

interface LicenseFileManagerInterface in Commerce File 8.2

Hierarchy

Expanded class hierarchy of LicenseFileManagerInterface

All classes that implement LicenseFileManagerInterface

3 files declare their use of LicenseFileManagerInterface
DownloadLimit.php in src/Plugin/views/field/DownloadLimit.php
FileDownloadController.php in src/Controller/FileDownloadController.php
FileResponseSubscriber.php in src/EventSubscriber/FileResponseSubscriber.php

File

src/LicenseFileManagerInterface.php, line 10

Namespace

Drupal\commerce_file
View source
interface LicenseFileManagerInterface {

  /**
   * Gets whether the licensed file can be downloaded.
   *
   * The logic first checks whether the current user has the permission to
   * bypass the license control or administer licenses, and then check the
   * download limits.
   *
   * @param \Drupal\commerce_license\Entity\LicenseInterface $license
   *   The license entity.
   * @param \Drupal\file\FileInterface $file
   *   The file entity.
   * @param \Drupal\Core\Session\AccountInterface|null $account
   *   The user to check for. When omitted, the license owner is used instead.
   *
   * @return bool
   *   Whether the given licensed file can be downloaded by the current user.
   */
  public function canDownload(LicenseInterface $license, FileInterface $file, AccountInterface $account = NULL);

  /**
   * Returns active licenses for the given file and the given user, optionally
   * restricted to licenses referencing the given purchasable entity.
   *
   * A file could be sold from multiple products. The user's active licenses
   * for all of them are loaded, and the first eligible one is returned.
   *
   * @param \Drupal\file\FileInterface $file
   *   The file.
   * @param \Drupal\Core\Session\AccountInterface|null $account
   *   The account to check for. If null, the current user is used instead.
   * @param \Drupal\commerce\PurchasableEntityInterface|null $purchasable_entity
   *   (optional) The purchasable entity.
   *
   * @return \Drupal\commerce_license\Entity\LicenseInterface[]
   *   The active licenses for the given file if found, an empty array
   *   otherwise.
   */
  public function getActiveLicenses(FileInterface $file, AccountInterface $account = NULL, PurchasableEntityInterface $purchasable_entity = NULL);

  /**
   * Gets the download limit for the given license.
   *
   * Note that the logic both checks for the global limit and a limit configured
   * at the product variation level (if overriden).
   *
   * @param \Drupal\commerce_license\Entity\LicenseInterface $license
   *   The license entity.
   *
   * @return int
   *   The download limit (0 for unlimited).
   */
  public function getDownloadLimit(LicenseInterface $license);

  /**
   * Gets whether the given file is licensable.
   *
   * @param \Drupal\file\FileInterface $file
   *   The file.
   *
   * @return bool
   *   Whether the given file is licensable.
   */
  public function isLicensable(FileInterface $file);

  /**
   * Determines whether the download should be logged for the given license.
   *
   * @param \Drupal\commerce_license\Entity\LicenseInterface $license
   *   The license.
   * @param \Drupal\Core\Session\AccountInterface|null $account
   *   The account to check for. If null, the current user is used instead.
   *
   * @return bool
   *   Whether the download should be logged.
   */
  public function shouldLogDownload(LicenseInterface $license, AccountInterface $account = NULL);

  /**
   * Resets the internal static cache of licenses.
   */
  public function resetCache();

}

Members

Namesort descending Modifiers Type Description Overrides
LicenseFileManagerInterface::canDownload public function Gets whether the licensed file can be downloaded. 1
LicenseFileManagerInterface::getActiveLicenses public function Returns active licenses for the given file and the given user, optionally restricted to licenses referencing the given purchasable entity. 1
LicenseFileManagerInterface::getDownloadLimit public function Gets the download limit for the given license. 1
LicenseFileManagerInterface::isLicensable public function Gets whether the given file is licensable. 1
LicenseFileManagerInterface::resetCache public function Resets the internal static cache of licenses. 1
LicenseFileManagerInterface::shouldLogDownload public function Determines whether the download should be logged for the given license. 1