kernel v0.1.4

This commit is contained in:
2025-01-21 16:51:29 +03:00
parent b733a49738
commit 2664f7fd78
35 changed files with 1249 additions and 82 deletions

View File

@ -63,6 +63,20 @@ class AdminConsoleController extends ConsoleController
);
$this->out->r("create option active_admin_theme", "green");
$this->optionService->createFromParams(
key: "theme_paths",
value: "{\"paths\": [\"{KERNEL}/themes\", \"{APP}/themes\"]}",
label: "Пути к темам сайта"
);
$this->out->r("create option theme_paths", "green");
$this->optionService->createFromParams(
key: "active_theme",
value: "{KERNEL}/themes/default",
label: "Активная тема сайта"
);
$this->out->r("create option active_theme", "green");
$this->optionService->createFromParams(
key: "module_paths",
value: "{\"paths\": [\"{KERNEL_MODULES}\", \"{APP}/modules\"]}",
@ -72,7 +86,7 @@ class AdminConsoleController extends ConsoleController
$this->optionService->createFromParams(
key: "active_modules",
value: "{\"modules\":[\"admin_themes\", \"secure\", \"user\", \"menu\", \"post\", \"option\"]}",
value: "{\"modules\":[\"admin_themes\",\"themes\",\"secure\", \"user\", \"menu\", \"post\", \"option\"]}",
label: "Активные модули"
);
$this->out->r("create option active_modules", "green");
@ -133,6 +147,14 @@ class AdminConsoleController extends ConsoleController
]);
$this->out->r("create item menu admin-themes", "green");
$this->menuService->createItem([
"label" => "Темы сайта",
"url" => "/admin/settings/themes",
"slug" => "themes",
"parent_slug" => "settings"
]);
$this->out->r("create item menu themes", "green");
$this->menuService->createItem([
"label" => "Меню",
"url" => "/admin/settings/menu",

View File

@ -0,0 +1,73 @@
<?php
namespace kernel\console\controllers;
use kernel\console\ConsoleController;
use kernel\helpers\Files;
use kernel\helpers\Manifest;
use kernel\models\Option;
use kernel\services\AdminThemeService;
use kernel\services\ThemeService;
use ZipArchive;
class ThemeController extends ConsoleController
{
/**
* @throws \Exception
*/
public function actionInstallTheme(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing theme path "--path" specified');
}
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$themeService = new ThemeService();
if ($themeService->install($this->argv['path'])) {
$this->out->r("Тема сайта установлена", 'green');
} else {
$this->out->r("Ошибка установки темы сайта", 'red');
}
} else {
$this->out->r("Тема сайта не найдена", 'red');
}
}
/**
* @throws \Exception
*/
public function actionUninstallTheme(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing theme path "--path" specified');
}
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$themeService = new ThemeService();
$themeService->uninstall($this->argv['path']);
$this->out->r("Тема сайта удалена", 'green');
} else {
$this->out->r("Тема сайта не найдена", 'red');
}
}
/**
* @throws \Exception
*/
public function actionPackTheme(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing theme path "--path" specified');
}
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$themeService = new ThemeService();
$themeService->pack($this->argv['path']);
$this->out->r("Тема сайта заархивирована", 'green');
} else {
$this->out->r("Тема сайта не найдена", 'red');
}
}
}

View File

@ -41,6 +41,21 @@ App::$collector->group(["prefix" => "admin-theme"], callback: function (RouteCol
);
});
App::$collector->group(["prefix" => "theme"], callback: function (RouteCollector $router){
App::$collector->console('install',
[\kernel\console\controllers\ThemeController::class, 'actionInstallTheme'],
additionalInfo: ['description' => 'Установить тему сайта', 'params' => ['--path' => 'Путь к устанавливаемой теме']]
);
App::$collector->console('uninstall',
[\kernel\console\controllers\ThemeController::class, 'actionUninstallTheme'],
additionalInfo: ['description' => 'Удалить тему сайта', 'params' => ['--path' => 'Путь к удаляемой теме']]
);
App::$collector->console('pack',
[\kernel\console\controllers\ThemeController::class, 'actionPackTheme'],
additionalInfo: ['description' => 'Заархивировать тему сайта', 'params' => ['--path' => 'Путь к теме, которую нужно заархивировать']]
);
});
App::$collector->group(["prefix" => "secure"], callback: function (RouteCollector $router){
App::$collector->console('create-secret-key',
[\kernel\console\controllers\SecureController::class, 'actionCreateSecretKey'],