Skip to content

Commit b302ac8

Browse files
Merge pull request #12 from hexadog/develop
Develop
2 parents 176241e + 5106002 commit b302ac8

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
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: 11 additions & 18 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,18 +80,18 @@ 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
/**
9587
* Clear the themes cache if it is enabled.
96-
*
88+
*
9789
* @return bool
9890
*/
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;
@@ -109,7 +101,7 @@ public function clearCache(): bool
109101
* Check if theme with given name exists.
110102
*
111103
* @param string $name
112-
*
104+
*
113105
* @return boolean
114106
*/
115107
public function has(string $name = null)
@@ -119,7 +111,8 @@ public function has(string $name = null)
119111
$name = str_replace(['-theme', 'theme-'], '', $name);
120112
// Check if $name contains vendor
121113
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+
;
123116
} else {
124117
return $theme->getLowerName() === Str::lower($name);
125118
}
@@ -143,7 +136,8 @@ public function get(string $name = null)
143136
$name = str_replace(['-theme', 'theme-'], '', $name);
144137
// Check if $name contains vendor
145138
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+
;
147141
} else {
148142
return $theme->getLowerName() === Str::lower($name);
149143
}
@@ -404,7 +398,6 @@ protected function findThemes(): Collection
404398
}
405399
});
406400
} catch (ComposerLoaderException $e) {
407-
408401
}
409402

410403
return $themes;
@@ -417,7 +410,7 @@ protected function findThemes(): Collection
417410
*/
418411
protected function getCache(): Collection
419412
{
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 () {
421414
return $this->findThemes();
422415
});
423416
}

src/Traits/ComposerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private function json($file = null): Json
221221
}
222222

223223
return Arr::get($this->json, $file, function () use ($file) {
224-
return $this->json[$file] = new Json($this->getPath($file), app('files'));
224+
return $this->json[$file] = Json::make($this->getPath($file), app('files'));
225225
});
226226
}
227227

@@ -244,7 +244,7 @@ private function scan(string $path, string $class)
244244
$foundComposers = Finder::create()->files()->followLinks()->in($path)->exclude(['node_modules', 'vendor'])->name('composer.json');
245245

246246
foreach ($foundComposers as $foundComposer) {
247-
$composerJson = new Json($foundComposer, app('files'));
247+
$composerJson = Json::make($foundComposer, app('files'));
248248

249249
if ($composerJson->get('type') === $this->packageType) {
250250
$content->put($composerJson->get('name'), new $class(dirname($foundComposer)));

0 commit comments

Comments
 (0)