<?php declare(strict_types=1);

namespace App\Controller;

class TestController extends \App\Engine\Inertia\BaseInertiaController
{

    public function index(\Symfony\Component\HttpKernel\KernelInterface $kernel): \Symfony\Component\HttpFoundation\Response
    {
        if (!$kernel->isDebug()) {
            throw $this->createNotFoundException();
        }

        return $this->execute();
    }

    public function vue(
        \Symfony\Component\HttpKernel\KernelInterface $kernel,
    ): \Symfony\Component\HttpFoundation\Response {
        if (!$kernel->isDebug()) {
            throw $this->createNotFoundException();
        }

        $props = new \App\Engine\Inertia\TestProps();
        return $this->inertia->render($this->getVueComponent(), $this->getInertiaProps(props: $props));
    }

    public function getVueComponent(): string
    {
        return "Test";
    }

    public function getId(): string
    {
        return "Test";
    }

    protected function execute(): \Symfony\Component\HttpFoundation\Response
    {
        return $this->render("test.twig");
    }

    protected function getInertiaProps(?\App\Engine\Inertia\InertiaProps $props = null): array
    {
        $props = $props ?? new \App\Engine\Inertia\TestProps();
        $props->configuration = new \App\Engine\Inertia\ViewModels\ConfigurationViewModel();
        $props->configuration->pageMeta = new \App\Engine\PageMeta\PageMetaViewModel();
        $props->configuration->pageMeta->title = "TEST Vue (DEV only)";

        return parent::getInertiaProps($props);
    }

}
