Skip to content

Commit f0effc8

Browse files
fix(cache): Use cache facade
1 parent 579d7a1 commit f0effc8

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/Providers/PackageServiceProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use ReflectionClass;
77
use Illuminate\Support\Str;
88
use Illuminate\Routing\Router;
9-
use Illuminate\Cache\CacheManager;
109
use Illuminate\Filesystem\Filesystem;
1110
use Illuminate\Contracts\View\Factory;
1211
use Illuminate\Foundation\AliasLoader;
@@ -100,8 +99,7 @@ public function register(): void
10099
$this->app->singleton('themes-manager', function () {
101100
return new ThemesManager(
102101
app(Factory::class),
103-
app(Translator::class),
104-
app(CacheManager::class)
102+
app(Translator::class)
105103
);
106104
});
107105

src/ThemesManager.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Hexadog\ThemesManager\Exceptions\ThemeNotFoundException;
1212
use Hexadog\ThemesManager\Exceptions\ComposerLoaderException;
1313
use Hexadog\ThemesManager\Exceptions\ThemeNotActiveException;
14-
use Illuminate\Cache\CacheManager;
14+
use Illuminate\Support\Facades\Cache;
1515

1616
class ThemesManager
1717
{
@@ -44,25 +44,17 @@ class ThemesManager
4444
*/
4545
private $view;
4646

47-
/**
48-
* Cache Manager.
49-
*
50-
* @var \Illuminate\Cache\CacheManager
51-
*/
52-
private $cache;
53-
5447
/**
5548
* The constructor.
5649
*
5750
* @param \Illuminate\View\Factory $view
5851
* @param \Illuminate\Contracts\Translation\Translator $lang
5952
* @param \Illuminate\Cache\CacheManager $lang
6053
*/
61-
public function __construct(Factory $view, Translator $lang, CacheManager $cache)
54+
public function __construct(Factory $view, Translator $lang)
6255
{
6356
$this->view = $view;
6457
$this->lang = $lang;
65-
$this->cache = $cache;
6658

6759
if (Config::get('themes-manager.cache.enabled', false)) {
6860
$this->themes = $this->getCache();
@@ -88,7 +80,7 @@ public function all()
8880
*/
8981
public function buildCache(): bool
9082
{
91-
return $this->cache->put(Config::get('themes-manager.cache.key', 'themes-manager'), $this->findThemes(), Config::get('themes-manager.cache.lifetime', 86400));
83+
return Cache::put(Config::get('themes-manager.cache.key', 'themes-manager'), $this->findThemes(), Config::get('themes-manager.cache.lifetime', 86400));
9284
}
9385

9486
/**
@@ -99,7 +91,7 @@ public function buildCache(): bool
9991
public function clearCache(): bool
10092
{
10193
if (Config::get('themes-manager.cache.enabled', false) === true) {
102-
return $this->cache->forget(Config::get('themes-manager.cache.key', 'themes-manager'));
94+
return Cache::forget(Config::get('themes-manager.cache.key', 'themes-manager'));
10395
}
10496

10597
return true;
@@ -417,7 +409,7 @@ protected function findThemes(): Collection
417409
*/
418410
protected function getCache(): Collection
419411
{
420-
return $this->cache->remember(Config::get('themes-manager.cache.key', 'themes-manager'), Config::get('themes-manager.cache.lifetime', 86400), function () {
412+
return Cache::remember(Config::get('themes-manager.cache.key', 'themes-manager'), Config::get('themes-manager.cache.lifetime', 86400), function () {
421413
return $this->findThemes();
422414
});
423415
}

0 commit comments

Comments
 (0)