<?php
namespace App\Controller\Core;
use App\Entity\Core\Info;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
public function __construct(private readonly EntityManagerInterface $entityManager)
{
}
#[Route('/', name: 'abacus_core_homepage', defaults: ['scope' => 'abacus-matematik'])]
public function index(): RedirectResponse
{
$scope = $this->getParameter('abacus.scope');
if ($scope === 'gale' && $this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('login_redirect_route');
}
return $this->redirectToRoute('login');
}
#[Route('/student/kolofon', name: 'student_colophon')]
#[Route('/teacher/kolofon', name: 'teacher_colophon')]
public function showColophon(): Response
{
$colophonBody = $this->entityManager->getRepository(Info::class)->findOneBy(['key' => 'colophon_body']);
return $this->render('Core/Default/colophon/base.html.twig', [
'colophonBody' => $colophonBody ? $colophonBody->getValue() : ''
]);
}
}