From d3c7fef002ab2ae94a55e13f21903af252389933 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 12 Dec 2022 17:16:53 +0100 Subject: [PATCH] Revert condition in CacheManager to avoid excessive nesting --- src/CacheManager.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/CacheManager.php b/src/CacheManager.php index 8eddb67d..f80cd017 100644 --- a/src/CacheManager.php +++ b/src/CacheManager.php @@ -19,26 +19,26 @@ class CacheManager extends BaseCacheManager public function __call($method, $parameters) { // todo0 Make PrefixCacheTenancyBootstrapper work with tags - if (tenancy()->initialized) { - $tags = [config('tenancy.cache.tag_base') . tenant()?->getTenantKey()]; - - if ($method === 'tags') { - $count = count($parameters); - - if ($count !== 1) { - throw new \Exception("Method tags() takes exactly 1 argument. $count passed."); - } - - $names = $parameters[0]; - $names = (array) $names; // cache()->tags('foo') https://laravel.com/docs/9.x/cache#removing-tagged-cache-items - - return $this->store()->tags(array_merge($tags, $names)); - } - - return $this->store()->tags($tags)->$method(...$parameters); + if (! tenancy()->initialized) { + return parent::__call($method, $parameters); } - return parent::__call($method, $parameters); + $tags = [config('tenancy.cache.tag_base') . tenant()?->getTenantKey()]; + + if ($method === 'tags') { + $count = count($parameters); + + if ($count !== 1) { + throw new \Exception("Method tags() takes exactly 1 argument. $count passed."); + } + + $names = $parameters[0]; + $names = (array) $names; // cache()->tags('foo') https://laravel.com/docs/9.x/cache#removing-tagged-cache-items + + return $this->store()->tags(array_merge($tags, $names)); + } + + return $this->store()->tags($tags)->$method(...$parameters); } public function refreshStore(string|null $repository = null): void