1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 01:14:04 +00:00
tenancy/src/TenancyBootstrappers/CacheTenancyBoostrapper.php
Samuel Štancl 0fe6fbab82 typo
2019-09-16 15:00:36 +02:00

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;
});
}
}