<?php

namespace kernel\modules\post;

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

class PostModule 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_MODULES}/post/migrations");

        $this->menuService->createItem([
            "label" => "Посты",
            "url" => "/admin/post",
            "slug" => "post",
        ]);
    }

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