src/Controller/Core/DefaultController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Core;
  3. use App\Entity\Core\Info;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\RedirectResponse;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class DefaultController extends AbstractController
  10. {
  11. public function __construct(private readonly EntityManagerInterface $entityManager)
  12. {
  13. }
  14. #[Route('/', name: 'abacus_core_homepage', defaults: ['scope' => 'abacus-matematik'])]
  15. public function index(): RedirectResponse
  16. {
  17. $scope = $this->getParameter('abacus.scope');
  18. if ($scope === 'gale' && $this->isGranted('IS_AUTHENTICATED_FULLY')) {
  19. return $this->redirectToRoute('login_redirect_route');
  20. }
  21. return $this->redirectToRoute('login');
  22. }
  23. #[Route('/student/kolofon', name: 'student_colophon')]
  24. #[Route('/teacher/kolofon', name: 'teacher_colophon')]
  25. public function showColophon(): Response
  26. {
  27. $colophonBody = $this->entityManager->getRepository(Info::class)->findOneBy(['key' => 'colophon_body']);
  28. return $this->render('Core/Default/colophon/base.html.twig', [
  29. 'colophonBody' => $colophonBody ? $colophonBody->getValue() : ''
  30. ]);
  31. }
  32. }