1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 22:54:03 +00:00

Move Cache::macro() to a slightly more appropriate place

This commit is contained in:
lukinovec 2022-12-12 17:25:29 +01:00
parent d3c7fef002
commit 35a3412011
2 changed files with 5 additions and 4 deletions

View file

@ -23,10 +23,6 @@ class PrefixCacheTenancyBootstrapper implements TenancyBootstrapper
public function bootstrap(Tenant $tenant): void
{
Cache::macro('setStore', function ($store) {
$this->store = $store;
});
$this->originalPrefix = $this->config->get('cache.prefix');
$this->storeName = $this->config->get('cache.default');

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Stancl\Tenancy;
use Illuminate\Support\Facades\Cache;
use Illuminate\Cache\CacheManager as BaseCacheManager;
// todo move to Cache namespace?
@ -43,6 +44,10 @@ class CacheManager extends BaseCacheManager
public function refreshStore(string|null $repository = null): void
{
Cache::macro('setStore', function ($store) {
$this->store = $store;
});
$newStore = $this->resolve($repository ?? $this->getDefaultDriver())->getStore();
$this->driver($repository)->setStore($newStore);