From aaeba861eba3376c9be59804dfd37e09ccb7fcee Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Tue, 26 Nov 2019 15:43:18 +0200
Subject: [PATCH] Make it possible to define message subject and template in
 EmailAuthenticator. (#1513)

---
 .../VuFind/src/VuFind/Auth/EmailAuthenticator.php   | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php b/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php
index 5775a59d72c..2fe718eb32e 100644
--- a/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php
+++ b/module/VuFind/src/VuFind/Auth/EmailAuthenticator.php
@@ -128,11 +128,15 @@ class EmailAuthenticator implements \VuFind\I18n\Translator\TranslatorAwareInter
      * user details)
      * @param array  $urlParams Default parameters for the generated URL
      * @param string $linkRoute The route to use as the base url for the login link
+     * @param string $subject   Email subject
+     * @param string $template  Email message template
      *
      * @return void
      */
     public function sendAuthenticationLink($email, $data,
-        $urlParams, $linkRoute = 'myresearch-home'
+        $urlParams, $linkRoute = 'myresearch-home',
+        $subject = 'email_login_subject',
+        $template = 'Email/login-link.phtml'
     ) {
         $sessionContainer = $this->getSessionContainer();
 
@@ -168,14 +172,11 @@ class EmailAuthenticator implements \VuFind\I18n\Translator\TranslatorAwareInter
         );
         $viewParams['title'] = $this->config->Site->title;
 
-        $message = $this->viewRenderer->render(
-            'Email/login-link.phtml',
-            $viewParams
-        );
+        $message = $this->viewRenderer->render($template, $viewParams);
         $from = !empty($this->config->Mail->user_email_in_from)
             ? $email
             : ($this->config->Mail->default_from ?? $this->config->Site->email);
-        $subject = $this->translator->translate('email_login_subject');
+        $subject = $this->translator->translate($subject);
         $subject = str_replace('%%title%%', $viewParams['title'], $subject);
 
         $this->mailer->send($email, $from, $subject, $message);
-- 
GitLab