Extract System emails from enotify

- Removed every SYSTEM_EMAIL occurrence in enotify
- Introduced a "SystemMailBuilder" for build system emails
- Replaced every SYSTEM_EMAIL usage in the classes with calling this builder
- Added tests for this new Builder
- Split the email templates between "base" template for email and concrete usages for different use cases
This commit is contained in:
nupplaPhil 2020-02-01 20:08:54 +01:00
parent 74490d6594
commit 3291728059
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
18 changed files with 647 additions and 118 deletions

View file

@ -76,15 +76,13 @@ class Users extends BaseAdmin
$preamble = sprintf($preamble, $user['username'], DI::config()->get('config', 'sitename'));
$body = sprintf($body, DI::baseUrl()->get(), $user['nickname'], $result['password'], DI::config()->get('config', 'sitename'));
notification([
'type' => SYSTEM_EMAIL,
'language' => $user['language'],
'to_name' => $user['username'],
'to_email' => $user['email'],
'uid' => $user['uid'],
'subject' => DI::l10n()->t('Registration details for %s', DI::config()->get('config', 'sitename')),
'preamble' => $preamble,
'body' => $body]);
$email = DI::emailer()
->newSystemMail((!empty($user['language'])) ? DI::l10n()->withLang($user['language']) : DI::l10n())
->withMessage(DI::l10n()->t('Registration details for %s', DI::config()->get('config', 'sitename')), $preamble, $body)
->forUser($user['uid'] ?? 0)
->withRecipient($user['email'])
->build();
return DI::emailer()->send($email);
}
if (!empty($_POST['page_users_block'])) {