<?php

namespace kernel\app_themes\svo;

use kernel\modules\menu\service\MenuService;
use kernel\modules\option\service\OptionService;
use kernel\services\MigrationService;

class SvoTheme
{
    public MenuService $menuService;
    public MigrationService $migrationService;

    public OptionService $optionService;

    public function __construct()
    {
        $this->menuService = new MenuService();
        $this->migrationService = new MigrationService();
        $this->optionService = new OptionService();
    }

    /**
     * @throws \Exception
     */
    public function init(): void
    {
        OptionService::createFromParams('main_news_slider', json_encode(['ids' => []]), 'Слайдер на главной');

        $this->menuService->createItem([
            "label" => "Настройки темы",
            "url" => "/admin/svo-theme/settings",
            "slug" => "svo_theme_settings",
        ]);
    }

    public function deactivate(): void
    {
        OptionService::removeOptionByKey('main_news_slider');
        $this->menuService->removeItemBySlug("svo_theme_settings");
    }
}