You are here

public function EmailHandler::duplicateExists in Easy Email 8

Same name and namespace in other branches
  1. 2.0.x src/Service/EmailHandler.php \Drupal\easy_email\Service\EmailHandler::duplicateExists()

@inheritDoc

Overrides EmailHandlerInterface::duplicateExists

1 call to EmailHandler::duplicateExists()
EmailHandler::sendEmail in src/Service/EmailHandler.php
@inheritDoc

File

src/Service/EmailHandler.php, line 132

Class

EmailHandler

Namespace

Drupal\easy_email\Service

Code

public function duplicateExists(EasyEmailInterface $email) {
  if ($email
    ->hasField('key') && ($key = $email
    ->getKey())) {
    $email = $email
      ->createDuplicate();
    $this->userEvaluator
      ->evaluateUsers($email);
    $key = $this->tokenEvaluator
      ->replaceTokens($email, $key);
    $result = $this->emailStorage
      ->getQuery()
      ->condition('key', $key)
      ->exists('sent')
      ->range(0, 1)
      ->execute();
    if (!empty($result)) {
      return TRUE;
    }
  }
  return FALSE;
}