public function EmailHandler::preview in Easy Email 8
Same name and namespace in other branches
- 2.0.x src/Service/EmailHandler.php \Drupal\easy_email\Service\EmailHandler::preview()
@inheritDoc
Overrides EmailHandlerInterface::preview
File
- src/
Service/ EmailHandler.php, line 267
Class
Namespace
Drupal\easy_email\ServiceCode
public function preview(EasyEmailInterface $email, $params = []) {
$message = NULL;
if (!$email
->isNew() && isset($this->renderedPreviews[$email
->id()])) {
$message = $this->renderedPreviews[$email
->id()];
}
if (empty($message)) {
$this->tokenEvaluator
->evaluateTokens($email);
$params = $this
->generateEmailParams($email, $params);
$reply = $email
->getReplyToAddress();
$recipient_emails = $email
->getRecipientAddresses();
$default_langcode = $this->languageManager
->getDefaultLanguage()
->getId();
$to = implode(', ', $recipient_emails);
$message = $this->mailManager
->mail('easy_email', $email
->bundle(), $to, $default_langcode, $params, $reply, FALSE);
if (!$email
->isNew()) {
$this->renderedPreviews[$email
->id()] = $message;
}
}
return $message;
}