From 72d16d8efd64d3f2b4d9a45f06e1faaf780c7dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 27 Sep 2019 20:56:42 +0200 Subject: [PATCH] TenantConfig first draft --- src/Features/TenantConfig.php | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Features/TenantConfig.php 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