1 Commits
2.2.1 ... 2.1.1

Author SHA1 Message Date
24fe47f1e7 fix postfix private 2023-11-18 01:23:21 +07:00
7 changed files with 7 additions and 9 deletions

0
.gitignore vendored Executable file → Normal file
View File

0
composer.json Executable file → Normal file
View File

0
composer.lock generated Executable file → Normal file
View File

0
mirzaev/minimal/system/controller.php Executable file → Normal file
View File

4
mirzaev/minimal/system/core.php Executable file → Normal file
View File

@@ -90,9 +90,9 @@ final class core
* *
* @param ?string $uri Маршрут * @param ?string $uri Маршрут
* *
* @return string|int|null Ответ * @return ?string Сгенерированный ответ (HTML, JSON...)
*/ */
public function start(string $uri = null): string|int|null public function start(string $uri = null): ?string
{ {
// Обработка запроса // Обработка запроса
return $this->__get('router')->handle($uri, core: $this); return $this->__get('router')->handle($uri, core: $this);

0
mirzaev/minimal/system/model.php Executable file → Normal file
View File

12
mirzaev/minimal/system/router.php Executable file → Normal file
View File

@@ -51,11 +51,9 @@ final class router
* *
* @param ?string $uri URI запроса (https://domain.com/foo/bar) * @param ?string $uri URI запроса (https://domain.com/foo/bar)
* @param ?string $method Метод запроса (GET, POST, PUT...) * @param ?string $method Метод запроса (GET, POST, PUT...)
* @param ?core $core Инстанция системного ядра * @param ?core $core Инстанция системного ядра
*
* @return string|int|null Ответ
*/ */
public function handle(?string $uri = null, ?string $method = null, ?core $core = new core): string|int|null public function handle(?string $uri = null, ?string $method = null, ?core $core = new core): ?string
{ {
// Инициализация значений по умолчанию // Инициализация значений по умолчанию
$uri ??= $_SERVER['REQUEST_URI'] ?? '/'; $uri ??= $_SERVER['REQUEST_URI'] ?? '/';
@@ -117,16 +115,16 @@ final class router
if (array_key_exists($method, $data)) { if (array_key_exists($method, $data)) {
// Идентифицирован метод маршрута (GET, POST, PUT...) // Идентифицирован метод маршрута (GET, POST, PUT...)
$route = $data[$method]; $route = $data[$method];
if (class_exists($controller = $core->namespace . '\\controllers\\' . $route['controller'] . $core->controller::POSTFIX)) { if (class_exists($controller = $core->namespace . '\\controllers\\' . $route['controller'] . $core->controller::POSTFIX)) {
// Найден контроллер // Найден контроллер
// Инициализация инстанции ядра контроллера // Инициализация инстанции ядра контроллера
$controller = new $controller; $controller = new $controller;
// Инициализация инстанции ядра модели // Инициализация инстанции ядра модели
if (class_exists($model = $core->namespace . '\\models\\' . $route['model'] . $core->model::POSTFIX)); if (class_exists($model = $core->namespace . '\\models\\' . $route['model'] . $core->model::POSTFIX)) $controller->model = new $model;
// Вызов связанного с маршрутом методв и возврат (успех) // Вызов связанного с маршрутом методв и возврат (успех)
return $controller->{$route['method']}($data['vars'] + $_REQUEST, $_FILES); return $controller->{$route['method']}($data['vars'] + $_REQUEST, $_FILES);