1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 12:54:05 +00:00

Depend less on the default mailer by adding a static $mailer property

This commit is contained in:
lukinovec 2022-11-03 08:28:00 +01:00
parent 635b299950
commit 55aa49b18e

View file

@ -10,8 +10,6 @@ use Stancl\Tenancy\Contracts\Tenant;
class MailTenancyBootstrapper implements TenancyBootstrapper
{
protected array $originalConfig = [];
/**
* Tenant properties to be mapped to config (similarly to the TenantConfig feature).
*
@ -22,7 +20,11 @@ class MailTenancyBootstrapper implements TenancyBootstrapper
*/
public static array $credentialsMap = [];
public static function smtpCredentialsMap(): array
public static string|null $mailer = null;
protected array $originalConfig = [];
public static function smtpPreset(): array
{
return [
'mail.mailers.smtp.host' => 'smtp_host',
@ -34,13 +36,14 @@ class MailTenancyBootstrapper implements TenancyBootstrapper
public function __construct(protected Repository $config)
{
static::$mailer ??= $config->get('mail.default');
static::$credentialsMap = array_merge(static::$credentialsMap, $this->pickMapPreset() ?? []);
}
protected function pickMapPreset(): array|null
{
return match ($this->config->get('mail.default')) {
'smtp' => static::smtpCredentialsMap(),
return match (static::$mailer) {
'smtp' => static::smtpPreset(),
default => null,
};
}