diff --git a/src/Features/TenantConfig.php b/src/Features/TenantConfig.php new file mode 100644 index 00000000..0829a1e4 --- /dev/null +++ b/src/Features/TenantConfig.php @@ -0,0 +1,44 @@ +app = $app; + } + + public function bootstrap(TenantManager $tenantManager): void + { + $tenantManager->eventListener('bootstrapped', function (TenantManager $manager) { + $this->setTenantConfig($manager->getTenant()); + }); + + $tenantManager->eventListener('ended', function () { + $this->unsetTenantConfig(); + }); + } + + public function setTenantConfig(Tenant $tenant): void + { + foreach($this->getStorageToConfigMap() as $storageKey => $configKey) { + $this->app['config'][$configKey] = $tenant->get($storageKey); + } + } + + public function getStorageToConfigMap(): array + { + return $this->app['config']['tenancy.storage_to_config_map'] ?? []; + } +} \ No newline at end of file