11
11
use Hexadog \ThemesManager \Exceptions \ThemeNotFoundException ;
12
12
use Hexadog \ThemesManager \Exceptions \ComposerLoaderException ;
13
13
use Hexadog \ThemesManager \Exceptions \ThemeNotActiveException ;
14
- use Illuminate \Cache \ CacheManager ;
14
+ use Illuminate \Support \ Facades \ Cache ;
15
15
16
16
class ThemesManager
17
17
{
@@ -44,25 +44,17 @@ class ThemesManager
44
44
*/
45
45
private $ view ;
46
46
47
- /**
48
- * Cache Manager.
49
- *
50
- * @var \Illuminate\Cache\CacheManager
51
- */
52
- private $ cache ;
53
-
54
47
/**
55
48
* The constructor.
56
49
*
57
50
* @param \Illuminate\View\Factory $view
58
51
* @param \Illuminate\Contracts\Translation\Translator $lang
59
52
* @param \Illuminate\Cache\CacheManager $lang
60
53
*/
61
- public function __construct (Factory $ view , Translator $ lang, CacheManager $ cache )
54
+ public function __construct (Factory $ view , Translator $ lang )
62
55
{
63
56
$ this ->view = $ view ;
64
57
$ this ->lang = $ lang ;
65
- $ this ->cache = $ cache ;
66
58
67
59
if (Config::get ('themes-manager.cache.enabled ' , false )) {
68
60
$ this ->themes = $ this ->getCache ();
@@ -88,18 +80,18 @@ public function all()
88
80
*/
89
81
public function buildCache (): bool
90
82
{
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 ));
92
84
}
93
85
94
86
/**
95
87
* Clear the themes cache if it is enabled.
96
- *
88
+ *
97
89
* @return bool
98
90
*/
99
91
public function clearCache (): bool
100
92
{
101
93
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 ' ));
103
95
}
104
96
105
97
return true ;
@@ -109,7 +101,7 @@ public function clearCache(): bool
109
101
* Check if theme with given name exists.
110
102
*
111
103
* @param string $name
112
- *
104
+ *
113
105
* @return boolean
114
106
*/
115
107
public function has (string $ name = null )
@@ -119,7 +111,8 @@ public function has(string $name = null)
119
111
$ name = str_replace (['-theme ' , 'theme- ' ], '' , $ name );
120
112
// Check if $name contains vendor
121
113
if (strpos ($ name , '/ ' ) !== false ) {
122
- return Str::lower ($ theme ->getName ()) === Str::lower (substr ($ name , $ pos + 1 , strlen ($ name )));;
114
+ return Str::lower ($ theme ->getName ()) === Str::lower (substr ($ name , $ pos + 1 , strlen ($ name )));
115
+ ;
123
116
} else {
124
117
return $ theme ->getLowerName () === Str::lower ($ name );
125
118
}
@@ -143,7 +136,8 @@ public function get(string $name = null)
143
136
$ name = str_replace (['-theme ' , 'theme- ' ], '' , $ name );
144
137
// Check if $name contains vendor
145
138
if (strpos ($ name , '/ ' ) !== false ) {
146
- return Str::lower ($ theme ->getName ()) === Str::lower (substr ($ name , $ pos + 1 , strlen ($ name )));;
139
+ return Str::lower ($ theme ->getName ()) === Str::lower (substr ($ name , $ pos + 1 , strlen ($ name )));
140
+ ;
147
141
} else {
148
142
return $ theme ->getLowerName () === Str::lower ($ name );
149
143
}
@@ -404,7 +398,6 @@ protected function findThemes(): Collection
404
398
}
405
399
});
406
400
} catch (ComposerLoaderException $ e ) {
407
-
408
401
}
409
402
410
403
return $ themes ;
@@ -417,7 +410,7 @@ protected function findThemes(): Collection
417
410
*/
418
411
protected function getCache (): Collection
419
412
{
420
- return $ this -> cache -> remember (Config::get ('themes-manager.cache.key ' , 'themes-manager ' ), Config::get ('themes-manager.cache.lifetime ' , 86400 ), function () {
413
+ return Cache:: remember (Config::get ('themes-manager.cache.key ' , 'themes-manager ' ), Config::get ('themes-manager.cache.lifetime ' , 86400 ), function () {
421
414
return $ this ->findThemes ();
422
415
});
423
416
}
0 commit comments