src/Controller/DefaultController.php line 34
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Offer;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
final class DefaultController extends AbstractController
{
public function __construct(private readonly EntityManagerInterface $em) {
}
/**
* Redirect to upload_index if connected, render homepage if not
*/
#[Route(path: '/', name: 'index')]
public function index(): Response
{
if ($this->isGranted('ROLE_USER')) {
return $this->redirectToRoute('upload_index');
} else {
return $this->render('index.html.twig', [
'subscriptions' => $this->em->getRepository(Offer::class)->findAll()
]);
}
}
#[Route(path: '/privacy_policy', name: 'privacy_policy')]
public function privacyPolicy(): Response
{
return $this->render('privacy_policy.html.twig');
}
}