diff --git a/framework/core/src/Api/Controller/ShowMailSettingsController.php b/framework/core/src/Api/Controller/ShowMailSettingsController.php index d699ee2b0..6fca5ffb1 100644 --- a/framework/core/src/Api/Controller/ShowMailSettingsController.php +++ b/framework/core/src/Api/Controller/ShowMailSettingsController.php @@ -41,11 +41,15 @@ class ShowMailSettingsController extends AbstractShowController $actual = self::$container->make('mail.driver'); $validator = self::$container->make(Factory::class); - $errors = $configured->validate($settings, $validator); + if (method_exists($configured, 'validate')) { + $errors = $configured->validate($settings, $validator); + } else { + $errors = new \Illuminate\Support\MessageBag; + } return [ 'drivers' => $drivers, - 'sending' => $actual->canSend(), + 'sending' => method_exists($actual, 'canSend') ? $actual->canSend() : true, 'errors' => $errors, ]; } diff --git a/framework/core/src/Mail/DriverInterface.php b/framework/core/src/Mail/DriverInterface.php index 17fa26aa9..44215a17f 100644 --- a/framework/core/src/Mail/DriverInterface.php +++ b/framework/core/src/Mail/DriverInterface.php @@ -10,8 +10,6 @@ namespace Flarum\Mail; use Flarum\Settings\SettingsRepositoryInterface; -use Illuminate\Contracts\Validation\Factory; -use Illuminate\Support\MessageBag; use Swift_Transport; /** @@ -46,12 +44,14 @@ interface DriverInterface * presence of validation problems with the configured mail driver, Flarum * will fall back to its no-op {@see \Flarum\Mail\NullDriver}. */ - public function validate(SettingsRepositoryInterface $settings, Factory $validator): MessageBag; + // TODO: Uncomment for beta.13 + //public function validate(SettingsRepositoryInterface $settings, Factory $validator): MessageBag; /** * Does this driver actually send out emails? */ - public function canSend(): bool; + // TODO: Uncomment for beta.13 + //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 024757f2f..34fd2b504 100644 --- a/framework/core/src/Mail/MailServiceProvider.php +++ b/framework/core/src/Mail/MailServiceProvider.php @@ -36,9 +36,13 @@ class MailServiceProvider extends AbstractServiceProvider $settings = $this->app->make(SettingsRepositoryInterface::class); $validator = $this->app->make(Factory::class); - return $configured->validate($settings, $validator)->any() - ? $this->app->make(NullDriver::class) - : $configured; + if (method_exists($configured, 'validate')) { + return $configured->validate($settings, $validator)->any() + ? $this->app->make(NullDriver::class) + : $configured; + } else { + return $configured; + } }); $this->app->alias('mail.driver', DriverInterface::class);