/** * Returns the cache identifier for the mail. * * @param \Drupal\simplenews\Mail\MailInterface $mail * The mail object. * * @return string */ protected function getCid(MailInterface $mail) { $entity_id = $mail->getEntity()->id(); return $mail->getEntity()->getEntityTypeId() . ':' . $entity_id . ':' . $mail->getLanguage(); }
/** * Constructor. * * @param MailInterface $mail The mail */ public function __construct(MailInterface $mail) { $mail->addTranslation($this); $this->mail = $mail; }
public function compose(MailInterface $mail) { $message = \Swift_Message::newInstance()->setSubject($mail->getSubject())->setFrom($this->from)->setTo($mail->getDestination())->setBody($this->renderEngine->render(self::$twigNamespace . '/' . $mail->getHTMLTemplate(), array('data' => $mail->getEntityArray())), 'text/html')->addPart($this->renderEngine->render(self::$twigNamespace . '/' . $mail->getTextTemplate(), array('data' => $mail->getEntityArray())), 'text/plain'); return $message; }