mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 06:43:01 +08:00
Require new mail driver methods, remove BC layer
This commit is contained in:
parent
ccf11480bf
commit
50ea61b524
|
@ -41,15 +41,11 @@ class ShowMailSettingsController extends AbstractShowController
|
|||
$actual = self::$container->make('mail.driver');
|
||||
$validator = self::$container->make(Factory::class);
|
||||
|
||||
if (method_exists($configured, 'validate')) {
|
||||
$errors = $configured->validate($settings, $validator);
|
||||
} else {
|
||||
$errors = new \Illuminate\Support\MessageBag;
|
||||
}
|
||||
$errors = $configured->validate($settings, $validator);
|
||||
|
||||
return [
|
||||
'drivers' => $drivers,
|
||||
'sending' => method_exists($actual, 'canSend') ? $actual->canSend() : true,
|
||||
'sending' => $actual->canSend(),
|
||||
'errors' => $errors,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
namespace Flarum\Mail;
|
||||
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Illuminate\Contracts\Validation\Factory;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Swift_Transport;
|
||||
|
||||
/**
|
||||
|
@ -44,14 +46,12 @@ interface DriverInterface
|
|||
* presence of validation problems with the configured mail driver, Flarum
|
||||
* will fall back to its no-op {@see \Flarum\Mail\NullDriver}.
|
||||
*/
|
||||
// TODO: Uncomment for beta.13
|
||||
//public function validate(SettingsRepositoryInterface $settings, Factory $validator): MessageBag;
|
||||
public function validate(SettingsRepositoryInterface $settings, Factory $validator): MessageBag;
|
||||
|
||||
/**
|
||||
* Does this driver actually send out emails?
|
||||
*/
|
||||
// TODO: Uncomment for beta.13
|
||||
//public function canSend(): bool;
|
||||
public function canSend(): bool;
|
||||
|
||||
/**
|
||||
* Build a mail transport based on Flarum's current settings.
|
||||
|
|
|
@ -35,13 +35,9 @@ class MailServiceProvider extends AbstractServiceProvider
|
|||
$settings = $this->app->make(SettingsRepositoryInterface::class);
|
||||
$validator = $this->app->make(Factory::class);
|
||||
|
||||
if (method_exists($configured, 'validate')) {
|
||||
return $configured->validate($settings, $validator)->any()
|
||||
? $this->app->make(NullDriver::class)
|
||||
: $configured;
|
||||
} else {
|
||||
return $configured;
|
||||
}
|
||||
return $configured->validate($settings, $validator)->any()
|
||||
? $this->app->make(NullDriver::class)
|
||||
: $configured;
|
||||
});
|
||||
|
||||
$this->app->alias('mail.driver', DriverInterface::class);
|
||||
|
|
Loading…
Reference in New Issue
Block a user