class WebformProtectedDownloadsManager in Webform Protected Downloads 8
Class WebformProtectedDownloadsManager.
@package Drupal\webform_protected_downloads
Hierarchy
- class \Drupal\webform_protected_downloads\WebformProtectedDownloadsManager implements ContainerInjectionInterface, WebformProtectedDownloadsManagerInterface
Expanded class hierarchy of WebformProtectedDownloadsManager
1 file declares its use of WebformProtectedDownloadsManager
1 string reference to 'WebformProtectedDownloadsManager'
1 service uses WebformProtectedDownloadsManager
File
- src/WebformProtectedDownloadsManager.php, line 15 
Namespace
Drupal\webform_protected_downloadsView source
class WebformProtectedDownloadsManager implements WebformProtectedDownloadsManagerInterface, ContainerInjectionInterface {
  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;
  /**
   * Constructs a GroupContentCardinalityValidator object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('entity_type.manager'));
  }
  /**
   * {@inheritdoc}
   */
  public function getSubmissionByUuid($uuid) {
    // Get all WebformProtectedDownloads.
    $webformProtectedDownloadEntities = WebformProtectedDownloads::loadMultiple();
    foreach ($webformProtectedDownloadEntities as $entity) {
      // Get WebformSubmission.
      $webformSubmission = $entity
        ->getWebformSubmission();
      // Compare uuid's.
      if ($webformSubmission
        ->uuid() == $uuid) {
        // Return WebformProtectedDownload.
        return $entity;
      }
      continue;
    }
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function getSubmissionByHash($hash) {
    $result = $this->entityTypeManager
      ->getStorage('webform_protected_downloads')
      ->getQuery()
      ->condition('hash', $hash)
      ->execute();
    // Return entity if exists or FALSE.
    if ($result) {
      return WebformProtectedDownloads::load(reset($result));
    }
    else {
      return FALSE;
    }
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| WebformProtectedDownloadsManager:: | protected | property | The entity type manager. | |
| WebformProtectedDownloadsManager:: | public static | function | Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: | |
| WebformProtectedDownloadsManager:: | public | function | Get WebformProtectedDownloads entity by hash. Overrides WebformProtectedDownloadsManagerInterface:: | |
| WebformProtectedDownloadsManager:: | public | function | Function will search submission by uuid. Overrides WebformProtectedDownloadsManagerInterface:: | |
| WebformProtectedDownloadsManager:: | public | function | Constructs a GroupContentCardinalityValidator object. | 
