MicroFrameWork/kernel/console/controllers/AdminThemeController.php

70 lines
2.1 KiB
PHP
Raw Normal View History

2024-09-11 17:38:46 +03:00
<?php
namespace kernel\console\controllers;
use kernel\console\ConsoleController;
use kernel\helpers\Files;
use kernel\helpers\Manifest;
2024-09-12 12:56:10 +03:00
use kernel\models\Option;
use kernel\services\AdminThemeService;
2024-09-11 17:38:46 +03:00
use ZipArchive;
class AdminThemeController extends ConsoleController
{
public function actionInstallTheme(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing admin theme path "--path" specified');
}
2024-12-23 14:14:59 +03:00
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$adminThemeService = new AdminThemeService();
if ($adminThemeService->install($this->argv['path'])) {
$this->out->r("Тема админ-панели установлена", 'green');
} else {
$this->out->r("Ошибка установки темы админ-панели", 'red');
}
2024-09-11 17:38:46 +03:00
} else {
2024-12-23 14:14:59 +03:00
$this->out->r("Тема админ-панели не найдена", 'red');
}
}
public function actionUninstallTheme(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing admin theme path "--path" specified');
2024-09-11 17:38:46 +03:00
}
2024-12-23 14:14:59 +03:00
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$adminThemeService = new AdminThemeService();
$adminThemeService->uninstall($this->argv['path']);
2024-09-11 17:38:46 +03:00
2024-12-23 14:14:59 +03:00
$this->out->r("Тема удалена", 'green');
} else {
$this->out->r("Тема не найдена", 'red');
2024-09-11 17:38:46 +03:00
}
2024-09-12 12:06:44 +03:00
}
2024-09-11 17:38:46 +03:00
2024-12-23 14:14:59 +03:00
/**
* @throws \Exception
*/
public function actionPackTheme(): void
2024-09-12 12:06:44 +03:00
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing admin theme path "--path" specified');
}
2024-09-11 17:38:46 +03:00
2024-09-12 12:06:44 +03:00
if (file_exists(ROOT_DIR . $this->argv['path'])) {
2024-12-23 14:14:59 +03:00
$adminThemeService = new AdminThemeService();
$adminThemeService->pack($this->argv['path']);
$this->out->r("Тема админ-панели заархивирована", 'green');
2024-09-12 12:06:44 +03:00
} else {
2024-12-23 14:14:59 +03:00
$this->out->r("Тема админ-панели не найдена", 'red');
2024-09-12 12:06:44 +03:00
}
2024-09-11 17:38:46 +03:00
}
}