From b00c005b097a0285a3190f5bfa0a5c6bee2d352b Mon Sep 17 00:00:00 2001 From: Kavalar Date: Thu, 12 Dec 2024 15:04:45 +0300 Subject: [PATCH] some fix --- kernel/console/controllers/MainController.php | 10 ++++++++++ kernel/console/controllers/ModuleController.php | 1 + kernel/console/routs/cli.php | 1 + kernel/services/ModuleService.php | 7 +++---- .../templates/controllers/kernel_controller_template | 2 +- kernel/templates/services/service_template | 2 +- kernel/templates/views/index_template | 6 ++++++ 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/kernel/console/controllers/MainController.php b/kernel/console/controllers/MainController.php index eecee1d..5878dd6 100644 --- a/kernel/console/controllers/MainController.php +++ b/kernel/console/controllers/MainController.php @@ -2,7 +2,9 @@ namespace kernel\console\controllers; +use kernel\App; use kernel\console\ConsoleController; +use kernel\helpers\Debug; class MainController extends ConsoleController { @@ -12,4 +14,12 @@ class MainController extends ConsoleController $this->out->r("Привет", "green"); } + public function actionHelp(): void + { +// Debug::dd(App::$collector->getData()); +// foreach (App::$collector->getDescriptions() as $description){ +// $this->out->r($description, "green"); +// } + } + } \ No newline at end of file diff --git a/kernel/console/controllers/ModuleController.php b/kernel/console/controllers/ModuleController.php index 92d05a4..2898770 100644 --- a/kernel/console/controllers/ModuleController.php +++ b/kernel/console/controllers/ModuleController.php @@ -113,6 +113,7 @@ class ModuleController extends ConsoleController 'model' => ucfirst($slug), 'author' => $author, 'name' => $name, + 'label' => $label, ]); $this->out->r("Модуль $slug создан", 'green'); diff --git a/kernel/console/routs/cli.php b/kernel/console/routs/cli.php index e95e2fe..1d3f68f 100644 --- a/kernel/console/routs/cli.php +++ b/kernel/console/routs/cli.php @@ -4,6 +4,7 @@ use kernel\App; use Phroute\Phroute\RouteCollector; App::$collector->console("hello", [\kernel\console\controllers\MainController::class, "indexAction"]); +App::$collector->console("help", [\kernel\console\controllers\MainController::class, "actionHelp"]); App::$collector->group(["prefix" => "migration"], callback: function (RouteCollector $router){ App::$collector->console('run', [\kernel\console\controllers\MigrationController::class, 'actionRun']); diff --git a/kernel/services/ModuleService.php b/kernel/services/ModuleService.php index 97240ee..27c511a 100644 --- a/kernel/services/ModuleService.php +++ b/kernel/services/ModuleService.php @@ -569,10 +569,9 @@ class ModuleService { $data = file_get_contents($templatePath); - $data = str_replace('{slug}', $params['slug'], $data); - $data = str_replace('{model}', $params['model'], $data); - $data = str_replace('{name}', $params['name'], $data); - $data = str_replace('{author}', $params['author'], $data); + foreach ($params as $key => $param){ + $data = str_replace("{" . $key . "}", $param, $data); + } file_put_contents($filePath, $data); } diff --git a/kernel/templates/controllers/kernel_controller_template b/kernel/templates/controllers/kernel_controller_template index 80309ad..fdadb54 100644 --- a/kernel/templates/controllers/kernel_controller_template +++ b/kernel/templates/controllers/kernel_controller_template @@ -7,7 +7,7 @@ use JetBrains\PhpStorm\NoReturn; use kernel\AdminController; use kernel\app_modules\{slug}\models\forms\Create{model}Form; use kernel\app_modules\{slug}\models\{model}; -use kernel\app_modules\{slug}\service\{model}Service; +use kernel\app_modules\{slug}\services\{model}Service; class {model}Controller extends AdminController { diff --git a/kernel/templates/services/service_template b/kernel/templates/services/service_template index 21878db..e456e4e 100644 --- a/kernel/templates/services/service_template +++ b/kernel/templates/services/service_template @@ -1,6 +1,6 @@ setTitle("Список {slug}"); +$view->setMeta([ + 'description' => 'Список {slug} системы' +]); + //Для использования таблицы с моделью, необходимо создать таблицу в базе данных //$table = new ListEloquentTable(new EloquentDataProvider({model}::class, [ // 'currentPage' => $page_number,