mirror of
https://github.com/flarum/core.git
synced 2025-10-12 07:24:27 +02:00
Extract Flarum\Notification namespace
This commit is contained in:
48
src/Notification/NotificationMailer.php
Normal file
48
src/Notification/NotificationMailer.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full 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;
|
||||
|
||||
class NotificationMailer
|
||||
{
|
||||
/**
|
||||
* @var Mailer
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* @param Mailer $mailer
|
||||
*/
|
||||
public function __construct(Mailer $mailer)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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());
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user