Commit 701862ed authored by Adam Shepherd's avatar Adam Shepherd
Browse files

Issue #3274899 by AdamPS: Set account/langcode from recipient

parent f4eb87d8
Loading
Loading
Loading
Loading
+2 −0
Changes for modules/symfony_mailer_bc/src/Plugin/EmailBuilder/ContactEmailBuilderBase.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ class ContactEmailBuilderBase extends EmailProcessorBase {
    $sender = $email->getParam('sender');
    $contact_message = $email->getParam('contact_message');

    // The contact entity cannot contain private information so we don't need
    // to switch account for rendering it.
    $email->appendBodyEntity($contact_message, 'mail')
      ->addLibrary('symfony_mailer_bc/contact')
      ->setVariable('subject', $contact_message->getSubject())
+4 −0
Changes for modules/symfony_mailer_bc/src/Plugin/EmailBuilder/ContactPageEmailBuilder.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ class ContactPageEmailBuilder extends ContactEmailBuilderBase implements MailerP
    $email->setVariable('form', $email->getEntity()->label())
      ->setVariable('form_url', Url::fromRoute('<current>')->toString());

    if ($email->getSubType() == 'mail') {
      // Set the account from the recipient to set langcode.
      $email->setAccount();
    }
    if ($email->getSubType() == 'autoreply') {
      $email->setBody($email->getParam('contact_form')->getReply());
    }
+1 −0
Changes for modules/symfony_mailer_bc/src/Plugin/EmailBuilder/SimplenewsNewsletterEmailBuilder.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ class SimplenewsNewsletterEmailBuilder extends EmailProcessorBase implements Mai
    $subscriber = $email->getParam('simplenews_subscriber');
    $email->setTo($subscriber->getMail())
      ->setLangcode($subscriber->getLangcode())
      ->setAccount($subscriber->getUser(), TRUE)
      ->appendBodyEntity($email->getParam('issue'), 'email_html')
      ->addTextHeader('Precedence', 'bulk')
      ->setVariable('opt_out_hidden', !$email->getEntity()->isAccessible())
+3 −1
Changes for modules/symfony_mailer_bc/src/Plugin/EmailBuilder/UpdateEmailBuilder.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -26,7 +26,9 @@ class UpdateEmailBuilder extends EmailProcessorBase {
    }

    $site_name = \Drupal::config('system.site')->get('name');
    $email->setVariable('site_name', $site_name)
    // Set the account from the recipient to set langcode.
    $email->setAccount()
      ->setVariable('site_name', $site_name)
      ->setVariable('update_status', Url::fromRoute('update.status')->toString())
      ->setVariable('update_settings', Url::fromRoute('update.settings')->toString())
      ->setVariable('messages', $messages);
+6 −2
Changes for modules/symfony_mailer_bc/src/Plugin/EmailBuilder/UserEmailBuilder.php: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ use Drupal\symfony_mailer\Processor\TokenProcessorTrait;
 *     "status_blocked" = @Translation("Account blocked"),
 *     "status_canceled" = @Translation("Account cancelled"),
 *   },
 *   common_adjusters = {"email_subject", "email_body"},
 *   common_adjusters = {"email_subject", "email_body", "email_skip_sending"},
 *   import = @Translation("User email settings"),
 *   import_warning = @Translation("This overrides the default HTML messages with imported plain text versions."),
 * )
@@ -43,7 +43,11 @@ class UserEmailBuilder extends EmailProcessorBase implements MailerPolicyImportI
   */
  public function build(EmailInterface $email) {
    if ($email->getSubType() != 'register_pending_approval_admin') {
      $email->setTo($email->getParam('user')->getEmail());
      $email->setAccount($email->getParam('user'));
    }
    else {
      // Set the account from the recipient to set langcode.
      $email->setAccount();
    }
    $this->tokenOptions(['callback' => 'user_mail_tokens', 'clear' => TRUE]);
  }
Loading