mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-14 00:14:04 +00:00
Delete CacheTenancyBootstrapper
This commit is contained in:
parent
7bbd5350c7
commit
840cd831d6
5 changed files with 9 additions and 63 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue