Commit fa7021d4 authored by Adam Shepherd's avatar Adam Shepherd
Browse files

Issue #3263447 by AdamPS: Extend hook_mailer_bc_alter() to allow altering 'to' and 'reply-to'

parent 7822ef6b
Loading
Loading
Loading
Loading
+3 −3
Changes for modules/symfony_mailer_bc/src/MailManagerReplacement.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class MailManagerReplacement extends MailManager {
   */
  public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {
    // Call alter hook.
    $context = ['module' => $module, 'entity' => NULL];
    $context = ['module' => $module, 'to' => $to, 'reply' => $reply, 'entity' => NULL];
    $this->moduleHandler->alter(['mailer_bc', "mailer_bc_$module"], $key, $params, $context);

    if ($entity = $context['entity']) {
@@ -64,10 +64,10 @@ class MailManagerReplacement extends MailManager {
      $email = $this->emailFactory->newModuleEmail($module, $key);
    }

    $email->setTo($to)
    $email->setTo($context['to'])
      ->setLangcode($langcode)
      ->setParams($params);
    if ($reply) {
    if ($context['reply']) {
      $email->setReplyTo($reply);
    }

+6 −2
Changes for modules/symfony_mailer_bc/symfony_mailer_bc.api.php: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@
 * @param array $params
 *   The email parameters.
 * @param array $context
 *   Array with two entries
 *   Array with entries:
 *   - module: The email type, known as 'module' on the old interface.
 *   - to: The email 'to' address.
 *   - reply: The email 'reply-to' address.
 *   - entity: The associated config entity, always null on the old interface.
 *
 * @see \Drupal\Core\Mail\MailManagerInterface::mail()
@@ -34,8 +36,10 @@ function hook_mailer_bc_alter(string &$key, array &$params, array &$context) {
 * @param array $params
 *   The email parameters.
 * @param array $context
 *   Array with two entries
 *   Array with entries:
 *   - module: The email type, known as 'module' on the old interface.
 *   - to: The email 'to' address.
 *   - reply: The email 'reply-to' address.
 *   - entity: The associated config entity, always null on the old interface.
 */
function hook_mailer_bc_MODULE_alter(string &$key, array &$params, array &$context) {