63 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace kernel\app_modules\event;
 | |
| 
 | |
| use kernel\app_modules\event\models\Event;
 | |
| use kernel\helpers\Debug;
 | |
| use kernel\Module;
 | |
| use kernel\modules\menu\service\MenuService;
 | |
| use kernel\services\MigrationService;
 | |
| 
 | |
| class EventModule extends Module
 | |
| {
 | |
| 
 | |
|     public MenuService $menuService;
 | |
|     public MigrationService $migrationService;
 | |
|     public function __construct()
 | |
|     {
 | |
|         $this->menuService = new MenuService();
 | |
|         $this->migrationService = new MigrationService();
 | |
|     }
 | |
| 
 | |
|     public function init(): void
 | |
|     {
 | |
|         $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/event/migrations");
 | |
| 
 | |
|         $this->menuService->createItem([
 | |
|             "label" => "Мероприятия",
 | |
|             "url" => "/admin/event",
 | |
|             "slug" => "event",
 | |
|         ]);
 | |
| 
 | |
|         $this->menuService->createItem([
 | |
|             "label" => "Список",
 | |
|             "url" => "/admin/event",
 | |
|             "slug" => "event_list",
 | |
|             "parent_slug" => "event",
 | |
|         ]);
 | |
|         $this->menuService->createItem([
 | |
|             "label" => "Создать",
 | |
|             "url" => "/admin/event/create",
 | |
|             "slug" => "event_create",
 | |
|             "parent_slug" => "event",
 | |
|         ]);
 | |
|         $this->menuService->createItem([
 | |
|             "label" => "Контакты",
 | |
|             "url" => "/admin/event-contacts",
 | |
|             "slug" => "event_contacts",
 | |
|             "parent_slug" => "event",
 | |
|         ]);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @throws \Exception
 | |
|      */
 | |
|     public function deactivate(): void
 | |
|     {
 | |
|         $this->migrationService->rollbackAtPath("{KERNEL_APP_MODULES}/event/migrations");
 | |
|         $this->menuService->removeItemBySlug("event_contacts");
 | |
|         $this->menuService->removeItemBySlug("event_create");
 | |
|         $this->menuService->removeItemBySlug("event_list");
 | |
|         $this->menuService->removeItemBySlug("event");
 | |
|     }
 | |
| } |