mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-14 04:34:02 +00:00
Make Tenancy override CacheManager
This commit is contained in:
parent
dc9c8fcf68
commit
9ec0b6dae3
3 changed files with 37 additions and 18 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy;
|
||||
|
||||
use Stancl\Tenancy\Enums\LogMode;
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Illuminate\Database\Console\Migrations\FreshCommand;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Domain;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Enums\LogMode;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Stancl\Tenancy\Events\Contracts\TenancyEvent;
|
||||
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
|
||||
use Stancl\Tenancy\CacheManager as TenantCacheManager;
|
||||
use Illuminate\Database\Console\Migrations\FreshCommand;
|
||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||
|
||||
class TenancyServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -97,6 +98,10 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
return new Commands\MigrateFreshOverride;
|
||||
});
|
||||
|
||||
$this->app->singleton('cache', function ($app) {
|
||||
return new TenantCacheManager($app);
|
||||
});
|
||||
|
||||
$this->publishes([
|
||||
__DIR__ . '/../assets/config.php' => config_path('tenancy.php'),
|
||||
], 'config');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue