From 41bf8ab56a71f8df90ea0332469cf46acd6a762d Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Thu, 21 Dec 2023 23:14:34 +0700 Subject: [PATCH] =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=87=D1=91=D1=82=D0=BE=20=D0=B7=D0=B0=D0=B1=D1=8B=D0=BB=20?= =?UTF-8?q?=D1=83=D0=B6=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 0 composer.json | 0 composer.lock | 0 mirzaev/minimal/system/controller.php | 0 mirzaev/minimal/system/core.php | 4 ++-- mirzaev/minimal/system/model.php | 0 mirzaev/minimal/system/router.php | 12 +++++++----- 7 files changed, 9 insertions(+), 7 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 composer.json mode change 100644 => 100755 composer.lock mode change 100644 => 100755 mirzaev/minimal/system/controller.php mode change 100644 => 100755 mirzaev/minimal/system/core.php mode change 100644 => 100755 mirzaev/minimal/system/model.php mode change 100644 => 100755 mirzaev/minimal/system/router.php diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 diff --git a/composer.lock b/composer.lock old mode 100644 new mode 100755 diff --git a/mirzaev/minimal/system/controller.php b/mirzaev/minimal/system/controller.php old mode 100644 new mode 100755 diff --git a/mirzaev/minimal/system/core.php b/mirzaev/minimal/system/core.php old mode 100644 new mode 100755 index 717ed09..7155d0d --- a/mirzaev/minimal/system/core.php +++ b/mirzaev/minimal/system/core.php @@ -90,9 +90,9 @@ final class core * * @param ?string $uri Маршрут * - * @return ?string Сгенерированный ответ (HTML, JSON...) + * @return string|int|null Ответ */ - public function start(string $uri = null): ?string + public function start(string $uri = null): string|int|null { // Обработка запроса return $this->__get('router')->handle($uri, core: $this); diff --git a/mirzaev/minimal/system/model.php b/mirzaev/minimal/system/model.php old mode 100644 new mode 100755 diff --git a/mirzaev/minimal/system/router.php b/mirzaev/minimal/system/router.php old mode 100644 new mode 100755 index ad878bf..40e21f6 --- a/mirzaev/minimal/system/router.php +++ b/mirzaev/minimal/system/router.php @@ -51,9 +51,11 @@ final class router * * @param ?string $uri URI запроса (https://domain.com/foo/bar) * @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 + public function handle(?string $uri = null, ?string $method = null, ?core $core = new core): string|int|null { // Инициализация значений по умолчанию $uri ??= $_SERVER['REQUEST_URI'] ?? '/'; @@ -115,16 +117,16 @@ final class router if (array_key_exists($method, $data)) { // Идентифицирован метод маршрута (GET, POST, PUT...) - $route = $data[$method]; + $route = $data[$method]; 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)) $controller->model = new $model; + if (class_exists($model = $core->namespace . '\\models\\' . $route['model'] . $core->model::POSTFIX)); // Вызов связанного с маршрутом методв и возврат (успех) return $controller->{$route['method']}($data['vars'] + $_REQUEST, $_FILES);