mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
Allow configuring all drivers via frontend (#1169)
This includes an API endpoint for fetching the list of possible drivers and their configuration fields. In the future, this can be extended to include more meta information about each field.
This commit is contained in:
@@ -24,6 +24,11 @@ use Swift_Transport;
|
||||
*/
|
||||
interface DriverInterface
|
||||
{
|
||||
/**
|
||||
* Provide a list of settings for this driver.
|
||||
*/
|
||||
public function availableSettings(): array;
|
||||
|
||||
/**
|
||||
* Build a mail transport based on Flarum's current settings.
|
||||
*/
|
||||
|
@@ -28,6 +28,11 @@ class LogDriver implements DriverInterface
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function availableSettings(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
|
||||
{
|
||||
return new LogTransport($this->logger);
|
||||
|
@@ -18,6 +18,14 @@ use Swift_Transport;
|
||||
|
||||
class MailgunDriver implements DriverInterface
|
||||
{
|
||||
public function availableSettings(): array
|
||||
{
|
||||
return [
|
||||
'mail_mailgun_secret', // the secret key
|
||||
'mail_mailgun_domain', // the API base URL
|
||||
];
|
||||
}
|
||||
|
||||
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
|
||||
{
|
||||
return new MailgunTransport(
|
||||
|
@@ -18,6 +18,13 @@ use Swift_Transport;
|
||||
|
||||
class MandrillDriver implements DriverInterface
|
||||
{
|
||||
public function availableSettings(): array
|
||||
{
|
||||
return [
|
||||
'mail_mandrill_secret',
|
||||
];
|
||||
}
|
||||
|
||||
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
|
||||
{
|
||||
return new MandrillTransport(
|
||||
|
@@ -17,6 +17,11 @@ use Swift_Transport;
|
||||
|
||||
class SendmailDriver implements DriverInterface
|
||||
{
|
||||
public function availableSettings(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
|
||||
{
|
||||
return new Swift_SendmailTransport;
|
||||
|
@@ -18,6 +18,15 @@ use Swift_Transport;
|
||||
|
||||
class SesDriver implements DriverInterface
|
||||
{
|
||||
public function availableSettings(): array
|
||||
{
|
||||
return [
|
||||
'mail_ses_key',
|
||||
'mail_ses_secret',
|
||||
'mail_ses_region',
|
||||
];
|
||||
}
|
||||
|
||||
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
|
||||
{
|
||||
$config = [
|
||||
|
@@ -17,6 +17,17 @@ use Swift_Transport;
|
||||
|
||||
class SmtpDriver implements DriverInterface
|
||||
{
|
||||
public function availableSettings(): array
|
||||
{
|
||||
return [
|
||||
'mail_host', // a hostname, IPv4 address or IPv6 wrapped in []
|
||||
'mail_port', // a number, defaults to 25
|
||||
'mail_encryption', // "tls" or "ssl"
|
||||
'mail_username', // required
|
||||
'mail_password', // required
|
||||
];
|
||||
}
|
||||
|
||||
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
|
||||
{
|
||||
$transport = new Swift_SmtpTransport(
|
||||
|
Reference in New Issue
Block a user