1
0
mirror of https://github.com/flarum/core.git synced 2025-10-11 23:14:29 +02:00
Files
php-flarum/src/Notification/NotificationMailer.php
Daniël Klabbers 84ded0ce50 Laravel components v8 (#2576)
- update actions ci
- include json for 4 spaces tab
- provide output int for process code exit
- adhere to parent type hint of builder
- mailer instance now needs a name, multiple can be instantiated
- getOriginal now uses mutators in the model
- Temporarily loosen MailableInterface requirements. This avoids an immediate BC break for classes in extensions that implement this interface.
- Temporarily provide (and autoload) old symfony translator interface
- make queue exception handler compatible with the contract of L8
- Update phpunit schema for newer version
- Update phpunit assert calls for newer version
2021-03-05 09:43:35 -05:00

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\Contracts\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));
}
);
}
}