admin init command
This commit is contained in:
94
kernel/console/controllers/AdminConsoleController.php
Normal file
94
kernel/console/controllers/AdminConsoleController.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\console\controllers;
|
||||
|
||||
use kernel\console\ConsoleController;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\modules\option\service\OptionService;
|
||||
use kernel\services\MigrationService;
|
||||
|
||||
class AdminConsoleController extends ConsoleController
|
||||
{
|
||||
|
||||
protected MigrationService $migrationService;
|
||||
protected OptionService $optionService;
|
||||
|
||||
public MenuService $menuService;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->migrationService = new MigrationService();
|
||||
$this->optionService = new OptionService();
|
||||
$this->menuService = new MenuService();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function actionInit(): void
|
||||
{
|
||||
$out = $this->migrationService->runAtPath("kernel/modules/menu/migrations");
|
||||
$this->out->r("create menu table", "green");
|
||||
|
||||
$out = $this->migrationService->runAtPath("kernel/modules/option/migrations");
|
||||
$this->out->r("create option table", "green");
|
||||
|
||||
$out = $this->migrationService->runAtPath("kernel/modules/user/migrations");
|
||||
$this->out->r("create user table", "green");
|
||||
|
||||
$out = $this->migrationService->runAtPath("kernel/modules/post/migrations");
|
||||
$this->out->r("create post table", "green");
|
||||
|
||||
$this->optionService->createFromParams(
|
||||
key: "admin_theme_paths",
|
||||
value: "{\"paths\": [\"{KERNEL_ADMIN_THEMES}\", \"{APP}/admin_themes\"]}",
|
||||
label: "Пути к темам админпанели"
|
||||
);
|
||||
$this->out->r("create option admin_theme_paths", "green");
|
||||
|
||||
$this->optionService->createFromParams(
|
||||
key: "active_admin_theme",
|
||||
value: "/home/kavlar/php/MicroFrameWork/kernel/admin_themes/default",
|
||||
label: "Активная тема админпанели"
|
||||
);
|
||||
$this->out->r("create option active_admin_theme", "green");
|
||||
|
||||
$this->optionService->createFromParams(
|
||||
key: "module_paths",
|
||||
value: "{\"paths\": [\"{KERNEL_MODULES}\", \"{APP}/modules\"]}",
|
||||
label: "Пути к модулям "
|
||||
);
|
||||
$this->out->r("create option module_paths", "green");
|
||||
|
||||
$this->optionService->createFromParams(
|
||||
key: "active_modules",
|
||||
value: "{\"modules\":[\"admin_themes\"]}",
|
||||
label: "Активные модули"
|
||||
);
|
||||
$this->out->r("create option active_modules", "green");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Модули",
|
||||
"url" => "/admin",
|
||||
"slug" => "module",
|
||||
]);
|
||||
$this->out->r("create item menu module", "green");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Настройки",
|
||||
"url" => "/admin/settings",
|
||||
"slug" => "settings",
|
||||
]);
|
||||
$this->out->r("create item menu settings", "green");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Темы админпанели",
|
||||
"url" => "/admin/settings/admin-themes",
|
||||
"slug" => "admin-themes",
|
||||
"parent_slug" => "settings"
|
||||
]);
|
||||
$this->out->r("create item menu admin-themes", "green");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user