<?php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use App\Entity\WorkspaceEntity;
use App\Repository\WorkspaceRepository;
use App\Form\WorkspaceAddForm;

/**
 * Main controller
 */
class MainController extends AbstractExtendedController
{

    /**
     * Workspace selector page
     *
     * @return Response
     */
    public function workspaceSelector(): Response
    {
        // Get repositories
        $entityManager = $this->getDoctrine()->getManager();
        /** @var workspaceRepository WorkspaceRepository */
        $workspaceRepository = $entityManager->getRepository(WorkspaceEntity::class);
        $workspaces = $workspaceRepository->findAll();
        
        // Add workspace form
        $workspaceAddForm = $this->createNamedCustomForm("addForm", WorkspaceAddForm::class);

        return $this->render("workspaceSelector.html.twig", [
            "workspaces" => $workspaces,
            "workspaceAddForm" => $workspaceAddForm,
        ]);
    }
}