1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-15 20:34:04 +00:00

Make Tenancy override CacheManager

This commit is contained in:
lukinovec 2022-12-12 17:05:53 +01:00
parent dc9c8fcf68
commit 9ec0b6dae3
3 changed files with 37 additions and 18 deletions

View file

@ -7,7 +7,6 @@ namespace Stancl\Tenancy\Bootstrappers;
use Illuminate\Cache\CacheManager;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Facades\Cache;
use Stancl\Tenancy\CacheManager as TenantCacheManager;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
@ -25,19 +24,12 @@ class CacheTenancyBootstrapper implements TenancyBootstrapper
$this->resetFacadeCache();
$this->originalCache = $this->originalCache ?? $this->app['cache'];
$this->app->extend('cache', function () {
return new TenantCacheManager($this->app);
});
}
public function revert(): void
{
$this->resetFacadeCache();
$this->app->extend('cache', function () {
return $this->originalCache;
});
$this->originalCache = null;
}