Skip to content

Commit 2e9286e

Browse files
chore(class): Clean up code
1 parent 2eef70c commit 2e9286e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/Theme.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function getPath(string $path = null): string
7777
*/
7878
public function getAssetsPath(string $path = null): string
7979
{
80-
return config('themes-manager.symlink_path', 'themes') . DIRECTORY_SEPARATOR . mb_strtolower($this->getName()) . DIRECTORY_SEPARATOR . $this->cleanPath($path);
80+
return Config::get('themes-manager.symlink_path', 'themes') . DIRECTORY_SEPARATOR . mb_strtolower($this->getName()) . DIRECTORY_SEPARATOR . $this->cleanPath($path);
8181
}
8282

8383
/**
@@ -237,22 +237,22 @@ public function url($url, $absolutePath = false): ?string
237237

238238
// Lookup asset in current's theme assets path
239239
$fullUrl = rtrim((empty($this->getAssetsPath()) ? '' : DIRECTORY_SEPARATOR) . $this->getAssetsPath($url), DIRECTORY_SEPARATOR);
240-
if (file_exists(public_path($fullUrl))) {
241-
$fullUrl = str_replace('\\', '/', $fullUrl);
242-
return $absolutePath ? asset('') . ltrim($fullUrl, '/') : ltrim($fullUrl, '/');
240+
if (File::exists(public_path($fullUrl))) {
241+
$fullUrl = ltrim(str_replace('\\', '/', $fullUrl), '/');
242+
return $absolutePath ? asset('') . $fullUrl : $fullUrl;
243243
}
244244

245245
// If not found then lookup in parent's theme assets path
246246
if ($parentTheme = $this->getParent()) {
247247
return $parentTheme->url($url, $absolutePath);
248248
} else { // No parent theme? Lookup in the public folder.
249-
if (file_exists(public_path($url))) {
250-
$url = ltrim(str_replace('\\', '/', $url));
251-
return $absolutePath ? asset('') . ltrim($url, '/') : ltrim($url, '/');
249+
if (File::exists(public_path($url))) {
250+
$url = ltrim(str_replace('\\', '/', $url), '/');
251+
return $absolutePath ? asset('') . $url : $url;
252252
}
253253
}
254254

255-
\Log::warning("Asset not found [{$url}] in Theme [{$this->getName()}]");
255+
\Log::warning("Asset [{$url}] not found for Theme [{$this->getName()}]");
256256

257257
return ltrim(str_replace('\\', '/', $url));
258258
}

src/ThemesManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Support\Collection;
77
use Illuminate\Filesystem\Filesystem;
88
use Illuminate\Contracts\View\Factory;
9+
use Illuminate\Support\Facades\Config;
910
use Hexadog\ThemesManager\Traits\ComposerTrait;
1011
use Illuminate\Contracts\Translation\Translator;
1112
use Hexadog\ThemesManager\Exceptions\ThemeNotFoundException;
@@ -58,7 +59,7 @@ public function __construct(Factory $view, Filesystem $files, Translator $lang)
5859
$this->view = $view;
5960
$this->files = $files;
6061
$this->lang = $lang;
61-
$this->basePath = config('themes-manager.directory', 'themes');
62+
$this->basePath = Config::get('themes-manager.directory', 'themes');
6263

6364
// Scan available themes per group
6465
try {

0 commit comments

Comments
 (0)