You are here

public function EmailTokenEvaluator::replaceTokens in Easy Email 2.0.x

Same name and namespace in other branches
  1. 8 src/Service/EmailTokenEvaluator.php \Drupal\easy_email\Service\EmailTokenEvaluator::replaceTokens()

@inheritDoc

Overrides EmailTokenEvaluatorInterface::replaceTokens

1 call to EmailTokenEvaluator::replaceTokens()
EmailTokenEvaluator::evaluateTokens in src/Service/EmailTokenEvaluator.php
@inheritDoc

File

src/Service/EmailTokenEvaluator.php, line 106

Class

EmailTokenEvaluator

Namespace

Drupal\easy_email\Service

Code

public function replaceTokens(EasyEmailInterface $email, $values, $unique = FALSE) {
  if (is_array($values)) {
    $replaced = [];
    foreach ($values as $key => $value) {
      $replaced[$key] = $this->token
        ->replace($value, [
        'easy_email' => $email,
      ]);
    }
    if ($unique) {
      $replaced = array_unique($replaced);
    }
    return $replaced;
  }
  return $this->token
    ->replace($values, [
    'easy_email' => $email,
  ]);
}