add default theme
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace kernel\services;
|
||||
|
||||
use kernel\helpers\Manifest;
|
||||
use kernel\models\Option;
|
||||
|
||||
class ThemeService
|
||||
@ -12,10 +13,10 @@ class ThemeService
|
||||
public function __construct()
|
||||
{
|
||||
$this->option = new Option();
|
||||
$this->findActiveAdminTheme();
|
||||
$this->findActiveTheme();
|
||||
}
|
||||
|
||||
public function findActiveAdminTheme(): void
|
||||
public function findActiveTheme(): void
|
||||
{
|
||||
$model = $this->option::where("key", "active_theme")->first();
|
||||
$this->active_theme = $model->value;
|
||||
@ -38,4 +39,26 @@ class ThemeService
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getThemeInfo(string $theme): false|array|string
|
||||
{
|
||||
$info = [];
|
||||
$theme = getConst($theme);
|
||||
$info['path'] = $theme;
|
||||
if (file_exists($theme . "/manifest.json")) {
|
||||
$manifest = file_get_contents($theme . "/manifest.json");
|
||||
$manifest = Manifest::getWithVars($manifest);
|
||||
$manifest['preview'] = $manifest['resource'] . "/" . $manifest['preview'];
|
||||
$info = array_merge($info, $manifest);
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function setActiveTheme(string $theme): void
|
||||
{
|
||||
$activeTheme = Option::where("key", "active_theme")->first();
|
||||
$activeTheme->value = getConst($theme);
|
||||
$activeTheme->save();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user