<?php

namespace kernel\app_modules\user_stage;

use kernel\helpers\Debug;
use kernel\Module;
use kernel\modules\menu\service\MenuService;
use kernel\services\MigrationService;

class UserStageModule 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}/user_stage/migrations");

        $this->menuService->createItem([
            "label" => "Этапы пользователя",
            "url" => "/admin/user_stage",
            "slug" => "user_stage",
        ]);
    }

    public function deactivate(): void
    {
        $this->migrationService->rollbackAtPath("{KERNEL_APP_MODULES}/user_stage/migrations");
        $this->menuService->removeItemBySlug("user_stage");
    }
}