mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 20:34:03 +00:00
Depend less on the default mailer by adding a static $mailer property
This commit is contained in:
parent
635b299950
commit
55aa49b18e
1 changed files with 8 additions and 5 deletions
|
|
@ -10,8 +10,6 @@ use Stancl\Tenancy\Contracts\Tenant;
|
||||||
|
|
||||||
class MailTenancyBootstrapper implements TenancyBootstrapper
|
class MailTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
protected array $originalConfig = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tenant properties to be mapped to config (similarly to the TenantConfig feature).
|
* 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 array $credentialsMap = [];
|
||||||
|
|
||||||
public static function smtpCredentialsMap(): array
|
public static string|null $mailer = null;
|
||||||
|
|
||||||
|
protected array $originalConfig = [];
|
||||||
|
|
||||||
|
public static function smtpPreset(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'mail.mailers.smtp.host' => 'smtp_host',
|
'mail.mailers.smtp.host' => 'smtp_host',
|
||||||
|
|
@ -34,13 +36,14 @@ class MailTenancyBootstrapper implements TenancyBootstrapper
|
||||||
|
|
||||||
public function __construct(protected Repository $config)
|
public function __construct(protected Repository $config)
|
||||||
{
|
{
|
||||||
|
static::$mailer ??= $config->get('mail.default');
|
||||||
static::$credentialsMap = array_merge(static::$credentialsMap, $this->pickMapPreset() ?? []);
|
static::$credentialsMap = array_merge(static::$credentialsMap, $this->pickMapPreset() ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function pickMapPreset(): array|null
|
protected function pickMapPreset(): array|null
|
||||||
{
|
{
|
||||||
return match ($this->config->get('mail.default')) {
|
return match (static::$mailer) {
|
||||||
'smtp' => static::smtpCredentialsMap(),
|
'smtp' => static::smtpPreset(),
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue