-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCacheManager.php
40 lines (30 loc) · 1.21 KB
/
CacheManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace App\Containers\Larabeans\Tenanter;
use Illuminate\Cache\CacheManager as BaseCacheManager;
class CacheManager extends BaseCacheManager
{
/**
* Add tags and forward the call to the inner cache store.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
$tags = [config('tenanter.cache.tag_base') . tenant()->getTenantKey()];
//if (method_exists($this->store()->getStore(), 'tags')) {
if($this->store()->getStore() instanceof \Illuminate\Cache\TaggableStore) {
if ($method === 'tags') {
if (count($parameters) !== 1) {
throw new \Exception("Method tags() takes exactly 1 argument. {count($parameters)} passed.");
}
$names = $parameters[0];
$names = (array) $names; // cache()->tags('foo') https://laravel.com/docs/5.7/cache#removing-tagged-cache-items
return $this->store()->tags(array_merge($tags, $names));
}
return $this->store()->tags($tags)->$method(...$parameters);
}
return $this->store()->$method(...$parameters);
}
}