diff --git a/app/modules/module_shop/ModuleShopModule.php b/app/modules/module_shop/ModuleShopModule.php new file mode 100644 index 0000000..f1e0e9a --- /dev/null +++ b/app/modules/module_shop/ModuleShopModule.php @@ -0,0 +1,34 @@ +menuService = new MenuService(); + $this->migrationService = new MigrationService(); + } + + public function init(): void + { + $this->migrationService->runAtPath("{APP}/modules/module_shop/migrations"); + + $this->menuService->createItem([ + "label" => "Магазин модулей", + "url" => "/admin/module_shop", + "slug" => "module_shop", + ]); + } + + public function deactivate(): void + { + $this->menuService->removeItemBySlug("module_shop"); + } +} \ No newline at end of file diff --git a/app/modules/module_shop/controllers/ModuleShopController.php b/app/modules/module_shop/controllers/ModuleShopController.php new file mode 100644 index 0000000..69da393 --- /dev/null +++ b/app/modules/module_shop/controllers/ModuleShopController.php @@ -0,0 +1,25 @@ +cgView->viewPath = KERNEL_APP_MODULES_DIR . "/module_shop/views/"; + $this->moduleService = new ModuleService(); + } + + public function actionIndex($page_number): void + { + $this->cgView->render("index.php", ['page_number' => $page_number]); + } + +} \ No newline at end of file diff --git a/app/modules/module_shop/manifest.json b/app/modules/module_shop/manifest.json new file mode 100644 index 0000000..57bfec0 --- /dev/null +++ b/app/modules/module_shop/manifest.json @@ -0,0 +1,11 @@ +{ + "name": "Магазин модулей", + "version": "0.1", + "author": "ITGuild", + "slug": "module_shop", + "description": "Магазин модулей для IGF", + "app_module_path": "{APP}/modules/{slug}", + "module_class": "app\\modules\\module_shop\\ModuleShopModule", + "routs": "routs/ms.php", + "dependence": "menu" +} diff --git a/app/modules/module_shop/migrations/2024_10_15_135454_create_module_shop_table.php b/app/modules/module_shop/migrations/2024_10_15_135454_create_module_shop_table.php new file mode 100644 index 0000000..195bfc7 --- /dev/null +++ b/app/modules/module_shop/migrations/2024_10_15_135454_create_module_shop_table.php @@ -0,0 +1,34 @@ +schema->create('module_shop', function (Blueprint $table) { + $table->increments('id'); + $table->string("name", 255)->nullable(false); + $table->string("slug", 255)->nullable(false); + $table->text("description")->nullable(false); + $table->string("version", 255)->nullable(false); + $table->string("author", 255)->nullable(false); + $table->string("dependence", 255)->nullable(true); + $table->text("path_to_archive")->nullable(false); + $table->integer("status")->default(1); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + \kernel\App::$db->schema->dropIfExists('module_shop'); + } +}; diff --git a/app/modules/module_shop/models/ModuleShop.php b/app/modules/module_shop/models/ModuleShop.php new file mode 100644 index 0000000..9eed21b --- /dev/null +++ b/app/modules/module_shop/models/ModuleShop.php @@ -0,0 +1,41 @@ + 'Название', + 'version' => 'Версия', + 'description' => 'Описание', + 'author' => 'Автор', + 'status' => 'Статус', + 'slug' => 'Slug', + 'path_to_archive' => 'Путь к файлу модуля', + 'dependence' => 'Зависимости', + ]; + } + + /** + * @return string[] + */ + public static function getStatus(): array + { + return [ + self::DISABLE_STATUS => "Не активный", + self::ACTIVE_STATUS => "Активный", + ]; + } + +} \ No newline at end of file diff --git a/app/modules/module_shop/routs/ms.php b/app/modules/module_shop/routs/ms.php new file mode 100644 index 0000000..9544ed2 --- /dev/null +++ b/app/modules/module_shop/routs/ms.php @@ -0,0 +1,21 @@ +group(["prefix" => "admin"], function (CgRouteCollector $router) { + App::$collector->group(["prefix" => "module_shop"], function (CgRouteCollector $router){ + App::$collector->get('/', [\app\modules\module_shop\controllers\ModuleShopController::class, 'actionIndex']); + App::$collector->get('/page/{page_number}', [\app\modules\module_shop\controllers\ModuleShopController::class, 'actionIndex']); +// App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']); +// App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']); +// App::$collector->get('/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']); +// App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']); +// App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']); +// App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']); + }); +}); + +App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){ + $router->rest("module_shop", [\app\modules\module_shop\controllers\ModuleShopController::class]); +}); \ No newline at end of file diff --git a/app/modules/module_shop/views/index.php b/app/modules/module_shop/views/index.php new file mode 100644 index 0000000..310a41f --- /dev/null +++ b/app/modules/module_shop/views/index.php @@ -0,0 +1,26 @@ + $page_number, + 'perPage' => 8, + 'params' => ["class" => "table table-bordered", "border" => "2"], + 'baseUrl' => "/admin/settings/menu", +])); +$table->beforePrint(function () { + return PrimaryBtn::create("Создать", "/admin/module_shop/create")->fetch(); + //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); +}); +$table->create(); +$table->render(); \ No newline at end of file