mirror of
https://github.com/flarum/core.git
synced 2025-07-28 04:00:40 +02:00
Mail Extender (#2012)
This allows registering new drivers, or overwriting existing ones.
This commit is contained in:
committed by
GitHub
parent
f0adb6a120
commit
0245df0573
38
framework/core/src/Extend/Mail.php
Normal file
38
framework/core/src/Extend/Mail.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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\Extend;
|
||||
|
||||
use Flarum\Extension\Extension;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class Mail implements ExtenderInterface
|
||||
{
|
||||
protected $drivers = [];
|
||||
|
||||
/**
|
||||
* Add a mail driver.
|
||||
*
|
||||
* @param string $identifier Identifier for mail driver. E.g. 'smtp' for SmtpDriver
|
||||
* @param string $driver ::class attribute of driver class, which must implement Flarum\Mail\DriverInterface
|
||||
*/
|
||||
public function driver(string $identifier, $driver)
|
||||
{
|
||||
$this->drivers[$identifier] = $driver;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function extend(Container $container, Extension $extension = null)
|
||||
{
|
||||
$container->extend('mail.supported_drivers', function ($existingDrivers) {
|
||||
return array_merge($existingDrivers, $this->drivers);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user