|
1
|
|
|
<?php namespace Modules\Setting\Repositories\Cache; |
|
2
|
|
|
|
|
3
|
|
|
use Modules\Core\Repositories\Cache\BaseCacheDecorator; |
|
4
|
|
|
use Modules\Setting\Repositories\SettingRepository; |
|
5
|
|
|
|
|
6
|
|
|
class CacheSettingDecorator extends BaseCacheDecorator implements SettingRepository |
|
7
|
|
|
{ |
|
8
|
|
|
public function __construct(SettingRepository $setting) |
|
9
|
|
|
{ |
|
10
|
|
|
parent::__construct(); |
|
11
|
|
|
$this->entityName = 'setting.settings'; |
|
12
|
|
|
$this->repository = $setting; |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Create or update the settings |
|
17
|
|
|
* @param $settings |
|
18
|
|
|
* @return mixed |
|
19
|
|
|
*/ |
|
20
|
|
|
public function createOrUpdate($settings) |
|
21
|
|
|
{ |
|
22
|
|
|
$this->cache->tags($this->entityName)->flush(); |
|
23
|
|
|
|
|
24
|
|
|
return $this->repository->createOrUpdate($settings); |
|
|
|
|
|
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Find a setting by its name |
|
29
|
|
|
* @param $settingName |
|
30
|
|
|
* @return mixed |
|
31
|
|
|
*/ |
|
32
|
|
View Code Duplication |
public function findByName($settingName) |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
return $this->cache |
|
35
|
|
|
->tags($this->entityName, 'global') |
|
36
|
|
|
->remember("{$this->locale}.{$this->entityName}.findByName.{$settingName}", $this->cacheTime, |
|
37
|
|
|
function () use ($settingName) { |
|
38
|
|
|
return $this->repository->findByName($settingName); |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Return all modules that have settings |
|
45
|
|
|
* with its settings |
|
46
|
|
|
* @param array|string $modules |
|
47
|
|
|
* @return array |
|
48
|
|
|
*/ |
|
49
|
|
View Code Duplication |
public function moduleSettings($modules) |
|
|
|
|
|
|
50
|
|
|
{ |
|
51
|
|
|
$moduleList = implode(',', $modules); |
|
52
|
|
|
|
|
53
|
|
|
return $this->cache |
|
54
|
|
|
->tags($this->entityName, 'global') |
|
55
|
|
|
->remember("{$this->locale}.{$this->entityName}.moduleSettings.{$moduleList}", $this->cacheTime, |
|
56
|
|
|
function () use ($modules) { |
|
57
|
|
|
return $this->repository->moduleSettings($modules); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Return the saved module settings |
|
64
|
|
|
* @param $module |
|
65
|
|
|
* @return mixed |
|
66
|
|
|
*/ |
|
67
|
|
View Code Duplication |
public function savedModuleSettings($module) |
|
|
|
|
|
|
68
|
|
|
{ |
|
69
|
|
|
return $this->cache |
|
70
|
|
|
->tags($this->entityName, 'global') |
|
71
|
|
|
->remember("{$this->locale}.{$this->entityName}.savedModuleSettings.{$module}", $this->cacheTime, |
|
72
|
|
|
function () use ($module) { |
|
73
|
|
|
return $this->repository->savedModuleSettings($module); |
|
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Find settings by module name |
|
80
|
|
|
* @param string $module |
|
81
|
|
|
* @return mixed |
|
82
|
|
|
*/ |
|
83
|
|
View Code Duplication |
public function findByModule($module) |
|
|
|
|
|
|
84
|
|
|
{ |
|
85
|
|
|
return $this->cache |
|
86
|
|
|
->tags($this->entityName, 'global') |
|
87
|
|
|
->remember("{$this->locale}.{$this->entityName}.findByModule.{$module}", $this->cacheTime, |
|
88
|
|
|
function () use ($module) { |
|
89
|
|
|
return $this->repository->findByModule($module); |
|
|
|
|
|
|
90
|
|
|
} |
|
91
|
|
|
); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Find the given setting name for the given module |
|
96
|
|
|
* @param string $settingName |
|
97
|
|
|
* @return mixed |
|
98
|
|
|
*/ |
|
99
|
|
View Code Duplication |
public function get($settingName) |
|
|
|
|
|
|
100
|
|
|
{ |
|
101
|
|
|
return $this->cache |
|
102
|
|
|
->tags($this->entityName, 'global') |
|
103
|
|
|
->remember("{$this->locale}.{$this->entityName}.get.{$settingName}", $this->cacheTime, |
|
104
|
|
|
function () use ($settingName) { |
|
105
|
|
|
return $this->repository->get($settingName); |
|
|
|
|
|
|
106
|
|
|
} |
|
107
|
|
|
); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Return the translatable module settings |
|
112
|
|
|
* @param $module |
|
113
|
|
|
* @return array |
|
114
|
|
|
*/ |
|
115
|
|
View Code Duplication |
public function translatableModuleSettings($module) |
|
|
|
|
|
|
116
|
|
|
{ |
|
117
|
|
|
return $this->cache |
|
118
|
|
|
->tags($this->entityName, 'global') |
|
119
|
|
|
->remember("{$this->locale}.{$this->entityName}.translatableModuleSettings.{$module}", $this->cacheTime, |
|
120
|
|
|
function () use ($module) { |
|
121
|
|
|
return $this->repository->translatableModuleSettings($module); |
|
|
|
|
|
|
122
|
|
|
} |
|
123
|
|
|
); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Return the non translatable module settings |
|
128
|
|
|
* @param $module |
|
129
|
|
|
* @return array |
|
130
|
|
|
*/ |
|
131
|
|
View Code Duplication |
public function plainModuleSettings($module) |
|
|
|
|
|
|
132
|
|
|
{ |
|
133
|
|
|
return $this->cache |
|
134
|
|
|
->tags($this->entityName, 'global') |
|
135
|
|
|
->remember("{$this->locale}.{$this->entityName}.plainModuleSettings.{$module}", $this->cacheTime, |
|
136
|
|
|
function () use ($module) { |
|
137
|
|
|
return $this->repository->plainModuleSettings($module); |
|
|
|
|
|
|
138
|
|
|
} |
|
139
|
|
|
); |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.