<?php

namespace kernel\app_modules\tag\controllers;

use Exception;
use JetBrains\PhpStorm\NoReturn;
use kernel\AdminController;
use kernel\app_modules\tag\models\forms\CreateTagForm;
use kernel\app_modules\tag\models\Tag;
use kernel\app_modules\tag\models\TagEntity;
use kernel\app_modules\tag\service\TagEntityService;
use kernel\app_modules\tag\service\TagService;
use kernel\helpers\Debug;
use kernel\modules\menu\service\MenuService;

class TagEntityController extends AdminController
{
    /**
     * @return void
     */
    protected function init(): void
    {
        parent::init();
        $this->cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tag/views/tag_entity/";
    }

    /**
     * @param $page_number
     * @return void
     */
    public function actionIndex($page_number = 1): void
    {
        $this->cgView->render("index.php", ['page_number' => $page_number]);
    }

    /**
     * @throws Exception
     */
    public function actionView($id): void
    {
        $tagEntity = TagEntity::find($id);

        if (!$tagEntity){
            throw new Exception(message: "The tag entity not found");
        }
        $this->cgView->render("view.php", ['tagEntity' => $tagEntity]);
    }

}