mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-14 04:44:04 +00:00
Fix file name
This commit is contained in:
parent
298b790e39
commit
8356557521
1 changed files with 0 additions and 0 deletions
40
src/TenancyBootstrappers/CacheTenancyBootstrapper.php
Normal file
40
src/TenancyBootstrappers/CacheTenancyBootstrapper.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\TenancyBootstrappers;
|
||||
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Stancl\Tenancy\CacheManager as TenantCacheManager;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Tenant;
|
||||
|
||||
class CacheTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
/** @var CacheManager */
|
||||
protected $originalCache;
|
||||
|
||||
/** @var Application */
|
||||
protected $app;
|
||||
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function start(Tenant $tenant)
|
||||
{
|
||||
$this->originalCache = $this->originalCache ?? $this->app['cache'];
|
||||
$this->app->extend('cache', function () {
|
||||
return new TenantCacheManager($this->app);
|
||||
});
|
||||
}
|
||||
|
||||
public function end()
|
||||
{
|
||||
$this->app->extend('cache', function () {
|
||||
return $this->originalCache;
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue