From c73ce3e7683421d911da7dadf037181101ec84bd Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Fri, 22 May 2020 18:10:31 -0400 Subject: [PATCH] Inject Url Generator and Translator Interface into notification mailer (#2169) --- .../src/Notification/NotificationMailer.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/framework/core/src/Notification/NotificationMailer.php b/framework/core/src/Notification/NotificationMailer.php index c298a8c78..36d3ef63c 100644 --- a/framework/core/src/Notification/NotificationMailer.php +++ b/framework/core/src/Notification/NotificationMailer.php @@ -9,9 +9,11 @@ namespace Flarum\Notification; +use Flarum\Http\UrlGenerator; use Flarum\User\User; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Mail\Message; +use Symfony\Component\Translation\TranslatorInterface; class NotificationMailer { @@ -21,11 +23,25 @@ class NotificationMailer protected $mailer; /** - * @param Mailer $mailer + * @var TranslatorInterface */ - public function __construct(Mailer $mailer) + protected $translator; + + /** + * @var UrlGenerator + */ + protected $url; + + /** + * @param Mailer $mailer + * @param TranslatorInterface $translator + * @param UrlGenerator $url + */ + public function __construct(Mailer $mailer, TranslatorInterface $translator, UrlGenerator $url) { $this->mailer = $mailer; + $this->translator = $translator; + $this->url = $url; } /** @@ -34,9 +50,11 @@ class NotificationMailer */ public function send(MailableInterface $blueprint, User $user) { + $translator = $this->translator; + $url = $this->url; $this->mailer->send( $blueprint->getEmailView(), - compact('blueprint', 'user'), + compact('blueprint', 'user', 'translator', 'url'), function (Message $message) use ($blueprint, $user) { $message->to($user->email, $user->username) ->subject($blueprint->getEmailSubject());