mirror of
https://github.com/flarum/framework.git
synced 2024-11-26 18:33:40 +08:00
Pass a translator instance to getEmailSubject on MailableInterface (#2244)
* Pass a translator instance to getMailSubject (breaking change) * Temporarily comment out getEmailSubject to avoid BC breaks
This commit is contained in:
parent
1dfb01d067
commit
3c3576c297
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace Flarum\Notification;
|
||||
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
interface MailableInterface
|
||||
{
|
||||
/**
|
||||
|
@ -23,5 +25,7 @@ interface MailableInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailSubject();
|
||||
// TODO: This is temporarily commented out to avoid BC breaks between beta 13 and beta 14.
|
||||
// It should be uncommented before beta 15.
|
||||
// public function getEmailSubject(TranslatorInterface $translator);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Flarum\Notification;
|
|||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
use Illuminate\Mail\Message;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class NotificationMailer
|
||||
{
|
||||
|
@ -21,11 +22,18 @@ class NotificationMailer
|
|||
protected $mailer;
|
||||
|
||||
/**
|
||||
* @param Mailer $mailer
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
public function __construct(Mailer $mailer)
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @param Mailer $mailer
|
||||
* @param TranslatorInterface $translator
|
||||
*/
|
||||
public function __construct(Mailer $mailer, TranslatorInterface $translator)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +47,7 @@ class NotificationMailer
|
|||
compact('blueprint', 'user'),
|
||||
function (Message $message) use ($blueprint, $user) {
|
||||
$message->to($user->email, $user->username)
|
||||
->subject($blueprint->getEmailSubject());
|
||||
->subject($blueprint->getEmailSubject($this->translator));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user