Skip to content
Snippets Groups Projects
Commit aaeba861 authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Make it possible to define message subject and template in EmailAuthenticator. (#1513)

parent 6f4ff3e5
No related merge requests found
...@@ -128,11 +128,15 @@ class EmailAuthenticator implements \VuFind\I18n\Translator\TranslatorAwareInter ...@@ -128,11 +128,15 @@ class EmailAuthenticator implements \VuFind\I18n\Translator\TranslatorAwareInter
* user details) * user details)
* @param array $urlParams Default parameters for the generated URL * @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 $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 * @return void
*/ */
public function sendAuthenticationLink($email, $data, 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(); $sessionContainer = $this->getSessionContainer();
...@@ -168,14 +172,11 @@ class EmailAuthenticator implements \VuFind\I18n\Translator\TranslatorAwareInter ...@@ -168,14 +172,11 @@ class EmailAuthenticator implements \VuFind\I18n\Translator\TranslatorAwareInter
); );
$viewParams['title'] = $this->config->Site->title; $viewParams['title'] = $this->config->Site->title;
$message = $this->viewRenderer->render( $message = $this->viewRenderer->render($template, $viewParams);
'Email/login-link.phtml',
$viewParams
);
$from = !empty($this->config->Mail->user_email_in_from) $from = !empty($this->config->Mail->user_email_in_from)
? $email ? $email
: ($this->config->Mail->default_from ?? $this->config->Site->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); $subject = str_replace('%%title%%', $viewParams['title'], $subject);
$this->mailer->send($email, $from, $subject, $message); $this->mailer->send($email, $from, $subject, $message);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment