Fix LESS import error and refactor project structure

This commit is contained in:
kirill.khorkov
2026-01-03 18:59:56 +03:00
parent 1bb0fc02e6
commit 4a8d4f8c3f
201 changed files with 891 additions and 14311 deletions

View File

@@ -2,35 +2,20 @@
namespace App\Core;
/**
* Controller - базовый класс контроллера
*/
abstract class Controller
{
/**
* Данные для передачи в представление
*/
protected array $data = [];
/**
* Отрендерить представление
*/
protected function view(string $view, array $data = [], string $layout = 'main'): void
{
echo View::render($view, $data, $layout);
}
/**
* Отрендерить представление без layout
*/
protected function viewPartial(string $view, array $data = []): void
{
echo View::render($view, $data, null);
}
/**
* Вернуть JSON ответ
*/
protected function json(array $data, int $statusCode = 200): void
{
http_response_code($statusCode);
@@ -39,18 +24,12 @@ abstract class Controller
exit;
}
/**
* Редирект на другой URL
*/
protected function redirect(string $url): void
{
header("Location: {$url}");
exit;
}
/**
* Получить текущего пользователя из сессии
*/
protected function getCurrentUser(): ?array
{
if (!isset($_SESSION['isLoggedIn']) || $_SESSION['isLoggedIn'] !== true) {
@@ -68,25 +47,16 @@ abstract class Controller
];
}
/**
* Проверить, авторизован ли пользователь
*/
protected function isAuthenticated(): bool
{
return isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] === true;
}
/**
* Проверить, является ли пользователь администратором
*/
protected function isAdmin(): bool
{
return $this->isAuthenticated() && isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] === true;
}
/**
* Требовать авторизацию
*/
protected function requireAuth(): void
{
if (!$this->isAuthenticated()) {
@@ -95,9 +65,6 @@ abstract class Controller
}
}
/**
* Требовать права администратора
*/
protected function requireAdmin(): void
{
if (!$this->isAdmin()) {
@@ -105,9 +72,6 @@ abstract class Controller
}
}
/**
* Получить POST данные
*/
protected function getPost(?string $key = null, $default = null)
{
if ($key === null) {
@@ -116,9 +80,6 @@ abstract class Controller
return $_POST[$key] ?? $default;
}
/**
* Получить GET данные
*/
protected function getQuery(?string $key = null, $default = null)
{
if ($key === null) {
@@ -127,17 +88,11 @@ abstract class Controller
return $_GET[$key] ?? $default;
}
/**
* Установить flash-сообщение
*/
protected function setFlash(string $type, string $message): void
{
$_SESSION['flash'][$type] = $message;
}
/**
* Получить flash-сообщение
*/
protected function getFlash(string $type): ?string
{
$message = $_SESSION['flash'][$type] ?? null;
@@ -145,4 +100,3 @@ abstract class Controller
return $message;
}
}