<?php

namespace kernel\modules\notification;

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

class NotificationModule 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/modules/notification/migrations");

        $this->menuService->createItem([
           "label" => "Уведомления",
            "url" => "/admin/notification",
            "slug" => "notification"
        ]);
    }

    /**
     * @throws \Exception
     */
    public function deactivate(): void
    {
        $this->migrationService->rollbackAtPath("kernel/modules/notification/migrations");
        $this->menuService->removeItemBySlug("notification");
    }
}