1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 01:14:04 +00:00

Replace Foundation\Application dependencies with Cache\Repository wherever possible (#149)

This commit is contained in:
Samuel Štancl 2019-09-30 17:10:39 +02:00 committed by GitHub
parent d0b1729258
commit eabac3d09f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 28 deletions

View file

@ -4,25 +4,25 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Features;
use Illuminate\Foundation\Application;
use Illuminate\Config\Repository;
use Stancl\Tenancy\Contracts\Feature;
use Stancl\Tenancy\Tenant;
use Stancl\Tenancy\TenantManager;
class TenantConfig implements Feature
{
/** @var Application */
protected $app;
/** @var Repository */
protected $config;
/** @var array */
public $originalConfig = [];
public function __construct(Application $app)
public function __construct(Repository $config)
{
$this->app = $app;
$this->config = $config;
foreach ($this->getStorageToConfigMap() as $configKey) {
$this->originalConfig[$configKey] = $this->app['config'][$configKey];
$this->originalConfig[$configKey] = $this->config[$configKey];
}
}
@ -40,19 +40,19 @@ class TenantConfig implements Feature
public function setTenantConfig(Tenant $tenant): void
{
foreach ($this->getStorageToConfigMap() as $storageKey => $configKey) {
$this->app['config'][$configKey] = $tenant->get($storageKey);
$this->config[$configKey] = $tenant->get($storageKey);
}
}
public function unsetTenantConfig(): void
{
foreach ($this->getStorageToConfigMap() as $configKey) {
$this->app['config'][$configKey] = $this->originalConfig[$configKey];
$this->config[$configKey] = $this->originalConfig[$configKey];
}
}
public function getStorageToConfigMap(): array
{
return $this->app['config']['tenancy.storage_to_config_map'] ?? [];
return $this->config['tenancy.storage_to_config_map'] ?? [];
}
}