mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
Allow mapping nested tenant properties to mail config (#20)
* Use data_get() to allow mapping nested tenant attributes to mail config * Fix code style (php-cs-fixer) * Test the data_get() change * Improve code, add info to docblock --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
This commit is contained in:
parent
ca400b51d2
commit
ea5a7463b8
3 changed files with 42 additions and 3 deletions
|
|
@ -16,7 +16,8 @@ class MailTenancyBootstrapper implements TenancyBootstrapper
|
|||
*
|
||||
* For example:
|
||||
* [
|
||||
* 'config.key.name' => 'tenant_property',
|
||||
* 'config.key.username' => 'tenant_property',
|
||||
* 'config.key.password' => 'nested.tenant_property',
|
||||
* ]
|
||||
*/
|
||||
public static array $credentialsMap = [];
|
||||
|
|
@ -60,9 +61,9 @@ class MailTenancyBootstrapper implements TenancyBootstrapper
|
|||
protected function setConfig(Tenant $tenant): void
|
||||
{
|
||||
foreach (static::$credentialsMap as $configKey => $storageKey) {
|
||||
$override = $tenant->$storageKey;
|
||||
$override = data_get($tenant, $storageKey);
|
||||
|
||||
if (array_key_exists($storageKey, $tenant->getAttributes())) {
|
||||
if ($override !== null) {
|
||||
$this->originalConfig[$configKey] ??= $this->config->get($configKey);
|
||||
|
||||
$this->config->set($configKey, $override);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue