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

Delete CacheTenancyBootstrapper

This commit is contained in:
lukinovec 2023-03-31 14:10:56 +02:00
parent 7bbd5350c7
commit 840cd831d6
5 changed files with 9 additions and 63 deletions

View file

@ -1,45 +0,0 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Bootstrappers;
use Illuminate\Cache\CacheManager;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Facades\Cache;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
class CacheTenancyBootstrapper implements TenancyBootstrapper
{
protected ?CacheManager $originalCache = null;
public function __construct(
protected Application $app
) {
}
public function bootstrap(Tenant $tenant): void
{
$this->resetFacadeCache();
$this->originalCache = $this->originalCache ?? $this->app['cache'];
}
public function revert(): void
{
$this->resetFacadeCache();
$this->originalCache = null;
}
/**
* This wouldn't be necessary, but is needed when a call to the
* facade has been made prior to bootstrapping tenancy. The
* facade has its own cache, separate from the container.
*/
public function resetFacadeCache(): void
{
Cache::clearResolvedInstances();
}
}