<?php

namespace App\Controller;

use App\Entity\Speaker;
use App\Entity\Template;
use App\Entity\Series;

use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends AbstractController
{
    #[Route('/', name: 'app_default')]
    public function index(EntityManagerInterface $emi): Response
    {
        $speakers = $emi->getRepository(Speaker::class)->findAll();
        $series = $emi->getRepository(Series::class)->findAll();
        $templates = $emi->getRepository(Template::class)->findAll();

        return $this->render('default/index.html.twig', [
            'controller_name' => 'DefaultController',
            'speakers' => $speakers,
            'series' => $series,
            'templates' => $templates
        ]);
    }

    #[Route('/template-editor', name: 'app_template_editor')]
    public function templateEditor(EntityManagerInterface $emi): Response
    {
        $templates = $emi->getRepository(Template::class)->findAll();
        return $this->render('default/template-editor.html.twig', [
            'templates' => $templates
        ]);
    }

    #[Route('/reference-editor', name: 'app_reference_editor')]
    public function referenceEditor(EntityManagerInterface $emi): Response
    {
        return $this->render('default/reference-editor.html.twig', []);
    }
}
