src/Controller/DefaultController.php line 34

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller;
  4. use App\Entity\Offer;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. final class DefaultController extends AbstractController
  10. {
  11.     public function __construct(private readonly EntityManagerInterface $em) {
  12.     }
  13.     /**
  14.      * Redirect to upload_index if connected, render homepage if not
  15.      */
  16.     #[Route(path'/'name'index')]
  17.     public function index(): Response
  18.     {
  19.         if ($this->isGranted('ROLE_USER')) {
  20.             return $this->redirectToRoute('upload_index');
  21.         } else {
  22.             return $this->render('index.html.twig', [
  23.                 'subscriptions' => $this->em->getRepository(Offer::class)->findAll()
  24.             ]);
  25.         }
  26.     }
  27.     #[Route(path'/privacy_policy'name'privacy_policy')]
  28.     public function privacyPolicy(): Response
  29.     {
  30.         return $this->render('privacy_policy.html.twig');
  31.     }
  32. }