mirror of
https://github.com/flarum/core.git
synced 2025-10-13 16:05:05 +02:00
* Pass a translator instance to getMailSubject (breaking change) * Temporarily comment out getEmailSubject to avoid BC breaks
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\Notification;
|
|
|
|
use Flarum\User\User;
|
|
use Illuminate\Contracts\Mail\Mailer;
|
|
use Illuminate\Mail\Message;
|
|
use Symfony\Component\Translation\TranslatorInterface;
|
|
|
|
class NotificationMailer
|
|
{
|
|
/**
|
|
* @var Mailer
|
|
*/
|
|
protected $mailer;
|
|
|
|
/**
|
|
* @var TranslatorInterface
|
|
*/
|
|
protected $translator;
|
|
|
|
/**
|
|
* @param Mailer $mailer
|
|
* @param TranslatorInterface $translator
|
|
*/
|
|
public function __construct(Mailer $mailer, TranslatorInterface $translator)
|
|
{
|
|
$this->mailer = $mailer;
|
|
$this->translator = $translator;
|
|
}
|
|
|
|
/**
|
|
* @param MailableInterface $blueprint
|
|
* @param User $user
|
|
*/
|
|
public function send(MailableInterface $blueprint, User $user)
|
|
{
|
|
$this->mailer->send(
|
|
$blueprint->getEmailView(),
|
|
compact('blueprint', 'user'),
|
|
function (Message $message) use ($blueprint, $user) {
|
|
$message->to($user->email, $user->username)
|
|
->subject($blueprint->getEmailSubject($this->translator));
|
|
}
|
|
);
|
|
}
|
|
}
|