diff --git a/framework/core/src/Api/Controller/ShowMailSettingsController.php b/framework/core/src/Api/Controller/ShowMailSettingsController.php index 6fca5ffb1..d699ee2b0 100644 --- a/framework/core/src/Api/Controller/ShowMailSettingsController.php +++ b/framework/core/src/Api/Controller/ShowMailSettingsController.php @@ -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, ]; } diff --git a/framework/core/src/Mail/DriverInterface.php b/framework/core/src/Mail/DriverInterface.php index 44215a17f..17fa26aa9 100644 --- a/framework/core/src/Mail/DriverInterface.php +++ b/framework/core/src/Mail/DriverInterface.php @@ -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. diff --git a/framework/core/src/Mail/MailServiceProvider.php b/framework/core/src/Mail/MailServiceProvider.php index c05491d6f..9b99d7ac0 100644 --- a/framework/core/src/Mail/MailServiceProvider.php +++ b/framework/core/src/Mail/MailServiceProvider.php @@ -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);