You are here

public function WebformProtectedDownloadsManager::getSubmissionByHash in Webform Protected Downloads 8

Get WebformProtectedDownloads entity by hash.

Parameters

string $hash: The hash.

Return value

mixed Return entity or false.

Overrides WebformProtectedDownloadsManagerInterface::getSubmissionByHash

File

src/WebformProtectedDownloadsManager.php, line 66

Class

WebformProtectedDownloadsManager
Class WebformProtectedDownloadsManager.

Namespace

Drupal\webform_protected_downloads

Code

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;
  }
}