Make application name configurable
* Added app_name configuration option * Extended `EngelsystemMailer` to prepend the application name to all mails Closes #426
This commit is contained in:
parent
0aa5f07925
commit
90e1a94962
|
@ -17,6 +17,9 @@ return [
|
||||||
// Enable maintenance mode (show a static page)
|
// Enable maintenance mode (show a static page)
|
||||||
'maintenance' => (bool)env('MAINTENANCE', false),
|
'maintenance' => (bool)env('MAINTENANCE', false),
|
||||||
|
|
||||||
|
// Application name (not the event name!)
|
||||||
|
'app_name' => env('APP_NAME', 'Engelsystem'),
|
||||||
|
|
||||||
// Set to development to enable debugging messages
|
// Set to development to enable debugging messages
|
||||||
'environment' => env('ENVIRONMENT', 'production'),
|
'environment' => env('ENVIRONMENT', 'production'),
|
||||||
|
|
||||||
|
@ -36,7 +39,7 @@ return [
|
||||||
'from' => [
|
'from' => [
|
||||||
// From address of all emails
|
// From address of all emails
|
||||||
'address' => env('MAIL_FROM_ADDRESS', 'noreply@engelsystem.de'),
|
'address' => env('MAIL_FROM_ADDRESS', 'noreply@engelsystem.de'),
|
||||||
'name' => env('MAIL_FROM_NAME', 'Engelsystem')
|
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Engelsystem'))
|
||||||
],
|
],
|
||||||
|
|
||||||
'host' => env('MAIL_HOST', 'localhost'),
|
'host' => env('MAIL_HOST', 'localhost'),
|
||||||
|
|
|
@ -16,7 +16,9 @@ require __DIR__ . '/includes.php';
|
||||||
* Check for maintenance
|
* Check for maintenance
|
||||||
*/
|
*/
|
||||||
if ($app->get('config')->get('maintenance')) {
|
if ($app->get('config')->get('maintenance')) {
|
||||||
echo file_get_contents(__DIR__ . '/../resources/views/layouts/maintenance.html');
|
$maintenance = file_get_contents(__DIR__ . '/../resources/views/layouts/maintenance.html');
|
||||||
|
$maintenance = str_replace('%APP_NAME%', $app->get('config')->get('app_name'), $maintenance);
|
||||||
|
echo $maintenance;
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ function mail_shift_change($old_shift, $new_shift)
|
||||||
if ($user['email_shiftinfo']) {
|
if ($user['email_shiftinfo']) {
|
||||||
engelsystem_email_to_user(
|
engelsystem_email_to_user(
|
||||||
$user,
|
$user,
|
||||||
'[engelsystem] ' . __('Your Shift has changed'),
|
__('Your Shift has changed'),
|
||||||
$message,
|
$message,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -90,7 +90,7 @@ function mail_shift_delete($shift)
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
if ($user['email_shiftinfo']) {
|
if ($user['email_shiftinfo']) {
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . __('Your Shift was deleted'), $message, true);
|
engelsystem_email_to_user($user, __('Your Shift was deleted'), $message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ function mail_shift_assign($user, $shift)
|
||||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||||
$message .= $room['Name'] . "\n";
|
$message .= $room['Name'] . "\n";
|
||||||
|
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . __('Assigned to Shift'), $message, true);
|
engelsystem_email_to_user($user, __('Assigned to Shift'), $message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,5 +134,5 @@ function mail_shift_removed($user, $shift)
|
||||||
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
$message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
|
||||||
$message .= $room['Name'] . "\n";
|
$message .= $room['Name'] . "\n";
|
||||||
|
|
||||||
engelsystem_email_to_user($user, '[engelsystem] ' . __('Removed from Shift'), $message, true);
|
engelsystem_email_to_user($user, __('Removed from Shift'), $message, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,10 @@ function mail_user_delete($user)
|
||||||
{
|
{
|
||||||
return engelsystem_email_to_user(
|
return engelsystem_email_to_user(
|
||||||
$user,
|
$user,
|
||||||
'[engelsystem] ' . __('Your account has been deleted'),
|
__('Your account has been deleted'),
|
||||||
__('Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven.')
|
__(
|
||||||
|
'Your %s account has been deleted. If you have any questions regarding your account deletion, please contact heaven.',
|
||||||
|
[config('app_name')]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,10 @@ function guest_register()
|
||||||
form_email('mail', __('E-Mail') . ' ' . entry_required(), $mail),
|
form_email('mail', __('E-Mail') . ' ' . entry_required(), $mail),
|
||||||
form_checkbox(
|
form_checkbox(
|
||||||
'email_shiftinfo',
|
'email_shiftinfo',
|
||||||
__('The engelsystem is allowed to send me an email (e.g. when my shifts change)'),
|
__(
|
||||||
|
'The %s is allowed to send me an email (e.g. when my shifts change)',
|
||||||
|
[config('app_name')]
|
||||||
|
),
|
||||||
$email_shiftinfo
|
$email_shiftinfo
|
||||||
),
|
),
|
||||||
form_checkbox(
|
form_checkbox(
|
||||||
|
|
|
@ -47,7 +47,7 @@ function make_atom_entries_from_news($news_entries)
|
||||||
$request = app('request');
|
$request = app('request');
|
||||||
$html = '<?xml version="1.0" encoding="utf-8"?>
|
$html = '<?xml version="1.0" encoding="utf-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<title>Engelsystem</title>
|
<title>' . config('app_name') . '</title>
|
||||||
<id>' . $request->getHttpHost()
|
<id>' . $request->getHttpHost()
|
||||||
. htmlspecialchars(preg_replace(
|
. htmlspecialchars(preg_replace(
|
||||||
'#[&?]key=[a-f\d]{32}#',
|
'#[&?]key=[a-f\d]{32}#',
|
||||||
|
|
|
@ -36,7 +36,7 @@ function send_ical_from_shifts($shifts)
|
||||||
{
|
{
|
||||||
header('Content-Type: text/calendar; charset=utf-8');
|
header('Content-Type: text/calendar; charset=utf-8');
|
||||||
header('Content-Disposition: attachment; filename=shifts.ics');
|
header('Content-Disposition: attachment; filename=shifts.ics');
|
||||||
$output = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//Engelsystem//DE\r\nCALSCALE:GREGORIAN\r\n";
|
$output = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//" . config('app_name') . "//DE\r\nCALSCALE:GREGORIAN\r\n";
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
$output .= make_ical_entry_from_shift($shift);
|
$output .= make_ical_entry_from_shift($shift);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows basic event infos and countdowns.
|
* Shows basic event infos and countdowns.
|
||||||
|
@ -24,7 +25,7 @@ function EventConfig_countdown_page()
|
||||||
$elements[] = div('col-sm-12 text-center', [
|
$elements[] = div('col-sm-12 text-center', [
|
||||||
heading(sprintf(
|
heading(sprintf(
|
||||||
__('Welcome to the %s!'),
|
__('Welcome to the %s!'),
|
||||||
$name . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'
|
$name . ' <span class="icon-icon_angel"></span> ' . Str::upper(config('app_name'))
|
||||||
), 2)
|
), 2)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,10 @@ function User_settings_view(
|
||||||
form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source['email']),
|
form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source['email']),
|
||||||
form_checkbox(
|
form_checkbox(
|
||||||
'email_shiftinfo',
|
'email_shiftinfo',
|
||||||
__('The engelsystem is allowed to send me an email (e.g. when my shifts change)'),
|
__(
|
||||||
|
'The %s is allowed to send me an email (e.g. when my shifts change)',
|
||||||
|
[config('app_name')]
|
||||||
|
),
|
||||||
$user_source['email_shiftinfo']
|
$user_source['email_shiftinfo']
|
||||||
),
|
),
|
||||||
form_checkbox(
|
form_checkbox(
|
||||||
|
|
Binary file not shown.
|
@ -2,7 +2,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Engelsystem 2.0\n"
|
"Project-Id-Version: Engelsystem 2.0\n"
|
||||||
"POT-Creation-Date: 2017-12-29 19:01+0100\n"
|
"POT-Creation-Date: 2017-12-29 19:01+0100\n"
|
||||||
"PO-Revision-Date: 2018-09-17 12:10+0200\n"
|
"PO-Revision-Date: 2018-10-05 15:35+0200\n"
|
||||||
"Last-Translator: msquare <msquare@notrademark.de>\n"
|
"Last-Translator: msquare <msquare@notrademark.de>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: de_DE\n"
|
"Language: de_DE\n"
|
||||||
|
@ -669,16 +669,18 @@ msgid "Hi %s,"
|
||||||
msgstr "Hallo %s,"
|
msgstr "Hallo %s,"
|
||||||
|
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:21
|
#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:21
|
||||||
msgid "here is a message for you from the engelsystem:"
|
#, php-format
|
||||||
msgstr "hier ist eine Nachricht aus dem Engelsystem für Dich:"
|
msgid "here is a message for you from the %s:"
|
||||||
|
msgstr "hier ist eine Nachricht aus dem %s für Dich:"
|
||||||
|
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:23
|
#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:23
|
||||||
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"This email is autogenerated and has not been signed. You got this email "
|
"This email is autogenerated and has not been signed. You got this email "
|
||||||
"because you are registered in the engelsystem."
|
"because you are registered in the %s."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Diese E-Mail wurde automatisch generiert und muss daher nicht unterschrieben "
|
"Diese E-Mail wurde automatisch generiert und muss daher nicht unterschrieben "
|
||||||
"werden. Du hast diese E-Mail bekommen, weil Du im Engelsystem registriert "
|
"werden. Du hast diese E-Mail bekommen, weil Du im %s registriert "
|
||||||
"bist."
|
"bist."
|
||||||
|
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:15
|
#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:15
|
||||||
|
@ -747,11 +749,12 @@ msgid "Your account has been deleted"
|
||||||
msgstr "Dein Konto wurde gelöscht."
|
msgstr "Dein Konto wurde gelöscht."
|
||||||
|
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/users_mailer.php:12
|
#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/users_mailer.php:12
|
||||||
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"Your angelsystem account has been deleted. If you have any questions "
|
"Your %s account has been deleted. If you have any questions "
|
||||||
"regarding your account deletion, please contact heaven."
|
"regarding your account deletion, please contact heaven."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Dein Engelsystem-Konto wurde gelöscht. Wenn Du dazu Fragen hast, kontaktiere "
|
"Dein %s-Konto wurde gelöscht. Wenn Du dazu Fragen hast, kontaktiere "
|
||||||
"bitte den Himmel."
|
"bitte den Himmel."
|
||||||
|
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:10
|
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:10
|
||||||
|
@ -1591,10 +1594,11 @@ msgstr ""
|
||||||
|
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:316
|
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:316
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:55
|
#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:55
|
||||||
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"The engelsystem is allowed to send me an email (e.g. when my shifts change)"
|
"The %s is allowed to send me an email (e.g. when my shifts change)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Das Engelsystem darf mir E-Mails senden (z.B. wenn sich meine Schichten "
|
"Das %s darf mir E-Mails senden (z.B. wenn sich meine Schichten "
|
||||||
"ändern)"
|
"ändern)"
|
||||||
|
|
||||||
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:321
|
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:321
|
||||||
|
|
Binary file not shown.
|
@ -2,7 +2,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Engelsystem 2.0\n"
|
"Project-Id-Version: Engelsystem 2.0\n"
|
||||||
"POT-Creation-Date: 2017-04-25 05:23+0200\n"
|
"POT-Creation-Date: 2017-04-25 05:23+0200\n"
|
||||||
"PO-Revision-Date: 2018-09-17 12:11+0200\n"
|
"PO-Revision-Date: 2018-10-05 15:35+0200\n"
|
||||||
"Last-Translator: samba <samba@autistici.org>\n"
|
"Last-Translator: samba <samba@autistici.org>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: pt_BR\n"
|
"Language: pt_BR\n"
|
||||||
|
@ -560,14 +560,16 @@ msgid "Hi %s,"
|
||||||
msgstr "Oi %s,"
|
msgstr "Oi %s,"
|
||||||
|
|
||||||
#: includes/helper/email_helper.php:12
|
#: includes/helper/email_helper.php:12
|
||||||
msgid "here is a message for you from the engelsystem:"
|
#, php-format
|
||||||
msgstr "aqui está uma mensagem do engelsystem para você:"
|
msgid "here is a message for you from the %s:"
|
||||||
|
msgstr "aqui está uma mensagem do %s para você:"
|
||||||
|
|
||||||
#: includes/helper/email_helper.php:12
|
#: includes/helper/email_helper.php:12
|
||||||
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"This email is autogenerated and has not been signed. You got this email "
|
"This email is autogenerated and has not been signed. You got this email "
|
||||||
"because you are registered in the engelsystem."
|
"because you are registered in the %s."
|
||||||
msgstr "Você recebeu esse email porque está registrado no engelsystem."
|
msgstr "Você recebeu esse email porque está registrado no %s."
|
||||||
|
|
||||||
#: includes/mailer/shifts_mailer.php:10
|
#: includes/mailer/shifts_mailer.php:10
|
||||||
msgid "A Shift you are registered on has changed:"
|
msgid "A Shift you are registered on has changed:"
|
||||||
|
@ -1344,10 +1346,11 @@ msgstr ""
|
||||||
"Esse script criará uma conta no sistema."
|
"Esse script criará uma conta no sistema."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:229 includes/view/User_view.php:50
|
#: includes/pages/guest_login.php:229 includes/view/User_view.php:50
|
||||||
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"The engelsystem is allowed to send me an email (e.g. when my shifts change)"
|
"The %s is allowed to send me an email (e.g. when my shifts change)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Permito que o engelsystem me envie emails (por exemplo, quando meus turnos "
|
"Permito que o %s me envie emails (por exemplo, quando meus turnos "
|
||||||
"mudam)"
|
"mudam)"
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:230 includes/view/User_view.php:51
|
#: includes/pages/guest_login.php:230 includes/view/User_view.php:51
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{ __('Hi %s,', [user]) }}
|
{{ __('Hi %s,', [user]) }}
|
||||||
|
|
||||||
{{ __('here is a message for you from the engelsystem:') }}
|
{{ __('here is a message for you from the %s:', [config('app_name')]) }}
|
||||||
{{ message|raw }}
|
{{ message|raw }}
|
||||||
|
|
||||||
{{ __('This email is autogenerated and has not been signed. You got this email because you are registered in the engelsystem.') }}
|
{{ __('This email is autogenerated and has not been signed. You got this email because you are registered in the %s.', [config('app_name')]) }}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<html lang="{{ session_get('locale')|split('_')[0]|escape('html_attr') }}">
|
<html lang="{{ session_get('locale')|split('_')[0]|escape('html_attr') }}">
|
||||||
<head>
|
<head>
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<title>{% block title %}{{ title }}{% endblock %} - Engelsystem</title>
|
<title>{% block title %}{{ title }}{% endblock %} - {{ config('app_name') }}</title>
|
||||||
|
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Maintenance - Engelsystem</title>
|
<title>Maintenance - %APP_NAME%</title>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" type="text/css" href="assets/theme0.css"/>
|
<link rel="stylesheet" type="text/css" href="assets/theme0.css"/>
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="#">
|
<a class="navbar-brand" href="#">
|
||||||
<span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
|
<span class="icon-icon_angel"></span> <strong class="visible-lg-inline">%APP_NAME%</strong>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
</h1>
|
</h1>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h2>
|
<h2>
|
||||||
The <span class="icon-icon_angel"></span> <strong>ENGELSYSTEM</strong> is in maintenance mode.
|
The <span class="icon-icon_angel"></span> <strong>%APP_NAME%</strong> is in maintenance mode.
|
||||||
</h2>
|
</h2>
|
||||||
<p>This may be due to...</p>
|
<p>This may be due to...</p>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="{{ url('/') }}">
|
<a class="navbar-brand" href="{{ url('/') }}">
|
||||||
<span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
|
<span class="icon-icon_angel"></span> <strong class="visible-lg-inline">{{ config('app_name')|upper }}</strong>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,13 @@ class EngelsystemMailer extends Mailer
|
||||||
/** @var Renderer|null */
|
/** @var Renderer|null */
|
||||||
protected $view;
|
protected $view;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $subjectPrefix = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param SwiftMailer $mailer
|
||||||
|
* @param Renderer $view
|
||||||
|
*/
|
||||||
public function __construct(SwiftMailer $mailer, Renderer $view = null)
|
public function __construct(SwiftMailer $mailer, Renderer $view = null)
|
||||||
{
|
{
|
||||||
parent::__construct($mailer);
|
parent::__construct($mailer);
|
||||||
|
@ -32,4 +39,37 @@ class EngelsystemMailer extends Mailer
|
||||||
|
|
||||||
return $this->send($to, $subject, $body);
|
return $this->send($to, $subject, $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the mail
|
||||||
|
*
|
||||||
|
* @param string|string[] $to
|
||||||
|
* @param string $subject
|
||||||
|
* @param string $body
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function send($to, string $subject, string $body): int
|
||||||
|
{
|
||||||
|
if ($this->subjectPrefix) {
|
||||||
|
$subject = sprintf('[%s] %s', $this->subjectPrefix, $subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::send($to, $subject, $body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSubjectPrefix(): string
|
||||||
|
{
|
||||||
|
return $this->subjectPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $subjectPrefix
|
||||||
|
*/
|
||||||
|
public function setSubjectPrefix(string $subjectPrefix)
|
||||||
|
{
|
||||||
|
$this->subjectPrefix = $subjectPrefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,10 @@ class MailerServiceProvider extends ServiceProvider
|
||||||
$this->app->instance(SwiftMailer::class, $swiftMailer);
|
$this->app->instance(SwiftMailer::class, $swiftMailer);
|
||||||
$this->app->instance('mailer.swift', $swiftMailer);
|
$this->app->instance('mailer.swift', $swiftMailer);
|
||||||
|
|
||||||
/** @var Mailer $mailer */
|
/** @var EngelsystemMailer $mailer */
|
||||||
$mailer = $this->app->make(EngelsystemMailer::class);
|
$mailer = $this->app->make(EngelsystemMailer::class);
|
||||||
$mailer->setFromAddress($mailConfig['from']['address']);
|
$mailer->setFromAddress($mailConfig['from']['address']);
|
||||||
|
$mailer->setSubjectPrefix($config->get('app_name'));
|
||||||
if (!empty($mailConfig['from']['name'])) {
|
if (!empty($mailConfig['from']['name'])) {
|
||||||
$mailer->setFromName($mailConfig['from']['name']);
|
$mailer->setFromName($mailConfig['from']['name']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Engelsystem\Renderer\Renderer;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Swift_Mailer as SwiftMailer;
|
use Swift_Mailer as SwiftMailer;
|
||||||
|
use Swift_Message as SwiftMessage;
|
||||||
|
|
||||||
class EngelsystemMailerTest extends TestCase
|
class EngelsystemMailerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -37,4 +38,53 @@ class EngelsystemMailerTest extends TestCase
|
||||||
$return = $mailer->sendView('foo@bar.baz', 'Lorem dolor', 'test/template.tpl', ['dev' => true]);
|
$return = $mailer->sendView('foo@bar.baz', 'Lorem dolor', 'test/template.tpl', ['dev' => true]);
|
||||||
$this->equalTo(1, $return);
|
$this->equalTo(1, $return);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \Engelsystem\Mail\EngelsystemMailer::send
|
||||||
|
* @covers \Engelsystem\Mail\EngelsystemMailer::setSubjectPrefix
|
||||||
|
* @covers \Engelsystem\Mail\EngelsystemMailer::getSubjectPrefix
|
||||||
|
*/
|
||||||
|
public function testSend()
|
||||||
|
{
|
||||||
|
/** @var SwiftMessage|MockObject $message */
|
||||||
|
$message = $this->createMock(SwiftMessage::class);
|
||||||
|
/** @var SwiftMailer|MockObject $swiftMailer */
|
||||||
|
$swiftMailer = $this->createMock(SwiftMailer::class);
|
||||||
|
$swiftMailer->expects($this->once())
|
||||||
|
->method('createMessage')
|
||||||
|
->willReturn($message);
|
||||||
|
$swiftMailer->expects($this->once())
|
||||||
|
->method('send')
|
||||||
|
->willReturn(1);
|
||||||
|
|
||||||
|
$message->expects($this->once())
|
||||||
|
->method('setTo')
|
||||||
|
->with(['to@xam.pel'])
|
||||||
|
->willReturn($message);
|
||||||
|
|
||||||
|
$message->expects($this->once())
|
||||||
|
->method('setFrom')
|
||||||
|
->with('foo@bar.baz', 'Lorem Ipsum')
|
||||||
|
->willReturn($message);
|
||||||
|
|
||||||
|
$message->expects($this->once())
|
||||||
|
->method('setSubject')
|
||||||
|
->with('[Mail test] Foo Bar')
|
||||||
|
->willReturn($message);
|
||||||
|
|
||||||
|
$message->expects($this->once())
|
||||||
|
->method('setBody')
|
||||||
|
->with('Lorem Ipsum!')
|
||||||
|
->willReturn($message);
|
||||||
|
|
||||||
|
$mailer = new EngelsystemMailer($swiftMailer);
|
||||||
|
$mailer->setFromAddress('foo@bar.baz');
|
||||||
|
$mailer->setFromName('Lorem Ipsum');
|
||||||
|
$mailer->setSubjectPrefix('Mail test');
|
||||||
|
|
||||||
|
$this->assertEquals('Mail test', $mailer->getSubjectPrefix());
|
||||||
|
|
||||||
|
$return = $mailer->send('to@xam.pel', 'Foo Bar', 'Lorem Ipsum!');
|
||||||
|
$this->equalTo(1, $return);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ class MailerServiceProviderTest extends ServiceProviderTest
|
||||||
{
|
{
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $defaultConfig = [
|
protected $defaultConfig = [
|
||||||
'email' => [
|
'app_name' => 'Engelsystem App',
|
||||||
|
'email' => [
|
||||||
'driver' => 'mail',
|
'driver' => 'mail',
|
||||||
'from' => [
|
'from' => [
|
||||||
'name' => 'Engelsystem',
|
'name' => 'Engelsystem',
|
||||||
|
@ -58,6 +59,7 @@ class MailerServiceProviderTest extends ServiceProviderTest
|
||||||
|
|
||||||
/** @var EngelsystemMailer $mailer */
|
/** @var EngelsystemMailer $mailer */
|
||||||
$mailer = $app->get('mailer');
|
$mailer = $app->get('mailer');
|
||||||
|
$this->assertEquals('Engelsystem App', $mailer->getSubjectPrefix());
|
||||||
$this->assertEquals('Engelsystem', $mailer->getFromName());
|
$this->assertEquals('Engelsystem', $mailer->getFromName());
|
||||||
$this->assertEquals('foo@bar.batz', $mailer->getFromAddress());
|
$this->assertEquals('foo@bar.batz', $mailer->getFromAddress());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue