kernel v0.1.4
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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user