install, uninstall. pack to ModuleService
This commit is contained in:
		| @@ -0,0 +1,38 @@ | ||||
| <?php | ||||
|  | ||||
| namespace app\modules\tag; | ||||
|  | ||||
| use kernel\Module; | ||||
| use kernel\modules\menu\service\MenuService; | ||||
| use kernel\services\MigrationService; | ||||
|  | ||||
| class TagModule extends Module | ||||
| { | ||||
|  | ||||
|     public MenuService $menuService; | ||||
|     public MigrationService $migrationService; | ||||
|     public function __construct() | ||||
|     { | ||||
|         $this->menuService = new MenuService(); | ||||
|         $this->migrationService = new MigrationService(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @throws \Exception | ||||
|      */ | ||||
|     public function init(): void | ||||
|     { | ||||
|         $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations"); | ||||
|  | ||||
|         $this->menuService->createItem([ | ||||
|             "label" => "Тэги", | ||||
|             "url" => "/admin/tag", | ||||
|             "slug" => "tag", | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
|     public function deactivate(): void | ||||
|     { | ||||
|         $this->menuService->removeItemBySlug("tag"); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,8 @@ | ||||
| <?php | ||||
|  | ||||
| namespace app\modules\tag\controllers; | ||||
|  | ||||
| class TagController extends \kernel\app_modules\tag\controllers\TagController | ||||
| { | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,12 @@ | ||||
| { | ||||
|   "name": "Tags", | ||||
|   "version": "0.1", | ||||
|   "author": "ITGuild", | ||||
|   "slug": "tag", | ||||
|   "description": "Tags module", | ||||
|   "app_module_path": "{APP}/modules/{slug}", | ||||
|   "kernel_module_path": "{KERNEL_APP_MODULES}/{slug}", | ||||
|   "module_class": "app\\modules\\tag\\TagModule", | ||||
|   "module_class_file": "{APP}/modules/tag/TagModule.php", | ||||
|   "routs": "routs/tag.php" | ||||
| } | ||||
| @@ -0,0 +1,2 @@ | ||||
| <?php | ||||
| include KERNEL_APP_MODULES_DIR . "/tag/routs/tag.php"; | ||||
		Reference in New Issue
	
	Block a user