kernel update to v0.1.5

This commit is contained in:
2025-01-24 11:33:08 +03:00
parent 4d7a2fbdec
commit 530908568c
5 changed files with 87 additions and 19 deletions

View File

@ -3,18 +3,31 @@
namespace kernel\modules\themes\controllers;
use DirectoryIterator;
use GuzzleHttp\Exception\GuzzleException;
use JetBrains\PhpStorm\NoReturn;
use Josantonius\Session\Exceptions\HeadersSentException;
use Josantonius\Session\Exceptions\SessionNotStartedException;
use Josantonius\Session\Exceptions\SessionStartedException;
use Josantonius\Session\Exceptions\WrongSessionOptionException;
use Josantonius\Session\Facades\Session;
use kernel\AdminController;
use kernel\helpers\Debug;
use kernel\models\Option;
use kernel\Request;
use kernel\services\ModuleService;
use kernel\services\ThemeService;
class ThemeController extends AdminController
{
public ThemeService $themeService;
public ModuleService $moduleService;
protected function init(): void
{
parent::init();
$this->cgView->viewPath = KERNEL_MODULES_DIR . "/themes/views/";
$this->themeService = new ThemeService();
$this->moduleService = new ModuleService();
}
public function actionIndex(): void
@ -62,10 +75,19 @@ class ThemeController extends AdminController
$this->cgView->render("index.php", ['json' => json_encode($infoToTable, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)]);
}
/**
* @throws HeadersSentException
* @throws WrongSessionOptionException
* @throws SessionStartedException
* @throws GuzzleException
* @throws SessionNotStartedException
*/
#[NoReturn] public function actionActivate(): void
{
$request = new Request();
$this->themeService->setActiveTheme($request->get("p"));
if(!$this->themeService->setActiveTheme($request->get("p"))){
$this->redirect("/admin/settings/themes/", 302);
}
$this->cgView->render("view.php", ['data' => $this->themeService->getThemeInfo($request->get("p"))]);
}