mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 14:14:03 +00:00
Add unsetTenantConfig
This commit is contained in:
parent
72d16d8efd
commit
6d12e629b8
1 changed files with 15 additions and 1 deletions
|
|
@ -14,9 +14,16 @@ class TenantConfig implements Feature
|
|||
/** @var Application */
|
||||
protected $app;
|
||||
|
||||
/** @var array */
|
||||
public $originalConfig = [];
|
||||
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
foreach ($this->getStorageToConfigMap() as $configKey) {
|
||||
$this->originalConfig[$configKey] = $this->app['config'][$configKey];
|
||||
}
|
||||
}
|
||||
|
||||
public function bootstrap(TenantManager $tenantManager): void
|
||||
|
|
@ -32,11 +39,18 @@ class TenantConfig implements Feature
|
|||
|
||||
public function setTenantConfig(Tenant $tenant): void
|
||||
{
|
||||
foreach($this->getStorageToConfigMap() as $storageKey => $configKey) {
|
||||
foreach ($this->getStorageToConfigMap() as $storageKey => $configKey) {
|
||||
$this->app['config'][$configKey] = $tenant->get($storageKey);
|
||||
}
|
||||
}
|
||||
|
||||
public function unsetTenantConfig(): void
|
||||
{
|
||||
foreach ($this->getStorageToConfigMap() as $configKey) {
|
||||
$this->app['config'][$configKey] = $this->originalConfig[$configKey];
|
||||
}
|
||||
}
|
||||
|
||||
public function getStorageToConfigMap(): array
|
||||
{
|
||||
return $this->app['config']['tenancy.storage_to_config_map'] ?? [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue