Do not die if "user_history" mail template cannot be loaded

This commit is contained in:
Dmitriy Simushev 2014-12-11 13:04:25 +00:00
parent 6768fe96c2
commit 8a47afef58

View File

@ -116,22 +116,25 @@ class MailController extends AbstractController
// Load mail templates and substitute placeholders there.
$mail_template = MailTemplate::loadByName('user_history', get_current_locale());
if (!$mail_template) {
throw new \RuntimeException('Cannot load "user_history" mail template');
if ($mail_template) {
$this->sendMail(MailUtils::buildMessage(
$email,
MIBEW_MAILBOX,
$mail_template->buildSubject(),
$mail_template->buildBody(array(
$thread->userName,
$history,
Settings::get('title'),
Settings::get('hosturl'),
))
));
} else {
trigger_error(
'Cannot send e-mail because "user_history" mail template cannot be loaded.',
E_USER_WARNING
);
}
$this->sendMail(MailUtils::buildMessage(
$email,
MIBEW_MAILBOX,
$mail_template->buildSubject(),
$mail_template->buildBody(array(
$thread->userName,
$history,
Settings::get('title'),
Settings::get('hosturl'),
))
));
$page = setup_logo($group);
$page['email'] = $email;