Theme module and them to igfs add
This commit is contained in:
73
kernel/console/controllers/ThemeController.php
Normal file
73
kernel/console/controllers/ThemeController.php
Normal 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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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'],
|
||||
|
Reference in New Issue
Block a user