mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:14:04 +00:00
Make credentials map a public static property
This commit is contained in:
parent
89cd781b4b
commit
54e286d367
1 changed files with 20 additions and 23 deletions
|
|
@ -13,13 +13,32 @@ class MailTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
protected array $originalConfig = [];
|
protected array $originalConfig = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tenant properties to be mapped to config (similarly the TenantConfig feature).
|
||||||
|
*
|
||||||
|
* For example:
|
||||||
|
* [
|
||||||
|
* 'property' => 'config.key.name',
|
||||||
|
* ]
|
||||||
|
*/
|
||||||
|
public static array $credentialsMap = [
|
||||||
|
'smtp_transport' => 'mail.mailers.smtp.transport',
|
||||||
|
'smtp_host' => 'mail.mailers.smtp.host',
|
||||||
|
'smtp_port' => 'mail.mailers.smtp.port',
|
||||||
|
'smtp_encryption' => 'mail.mailers.smtp.encryption',
|
||||||
|
'smtp_username' => 'mail.mailers.smtp.username',
|
||||||
|
'smtp_password' => 'mail.mailers.smtp.password',
|
||||||
|
'smtp_timeout' => 'mail.mailers.smtp.timeout',
|
||||||
|
'smtp_local_domain' => 'mail.mailers.smtp.local_domain',
|
||||||
|
];
|
||||||
|
|
||||||
public function __construct(protected Repository $config)
|
public function __construct(protected Repository $config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bootstrap(Tenant $tenant): void
|
public function bootstrap(Tenant $tenant): void
|
||||||
{
|
{
|
||||||
foreach ($this->credentialsMap() as $storageKey => $configKey) {
|
foreach (static::$credentialsMap as $storageKey => $configKey) {
|
||||||
/** @var Tenant&Model $tenant */
|
/** @var Tenant&Model $tenant */
|
||||||
$override = Arr::get($tenant, $storageKey);
|
$override = Arr::get($tenant, $storageKey);
|
||||||
|
|
||||||
|
|
@ -45,26 +64,4 @@ class MailTenancyBootstrapper implements TenancyBootstrapper
|
||||||
$this->config->set($key, $value);
|
$this->config->set($key, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tenant properties to be mapped to config (similarly the TenantConfig feature).
|
|
||||||
*
|
|
||||||
* For example:
|
|
||||||
* [
|
|
||||||
* 'property' => 'config.key.name',
|
|
||||||
* ]
|
|
||||||
*/
|
|
||||||
protected function credentialsMap()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'smtp_transport' => 'mail.mailers.smtp.transport',
|
|
||||||
'smtp_host' => 'mail.mailers.smtp.host',
|
|
||||||
'smtp_port' => 'mail.mailers.smtp.port',
|
|
||||||
'smtp_encryption' => 'mail.mailers.smtp.encryption',
|
|
||||||
'smtp_username' => 'mail.mailers.smtp.username',
|
|
||||||
'smtp_password' => 'mail.mailers.smtp.password',
|
|
||||||
'smtp_timeout' => 'mail.mailers.smtp.timeout',
|
|
||||||
'smtp_local_domain' => 'mail.mailers.smtp.local_domain',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue