mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:34:03 +00:00
39 lines
891 B
PHP
39 lines
891 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\TenancyBootstrappers;
|
|
|
|
use Illuminate\Cache\CacheManager;
|
|
use Illuminate\Contracts\Foundation\Application;
|
|
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 CacheManager($this->app);
|
|
});
|
|
}
|
|
|
|
public function end()
|
|
{
|
|
$this->app->extend('cache', function () {
|
|
return $this->originalCache;
|
|
});
|
|
}
|
|
}
|