src/Controller/DefaultController.php line 23
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Poll;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
private EntityManagerInterface $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
#[Route(path: '/', name: 'index', methods: ['GET'])]
public function index(): Response
{
$polls = $this->entityManager->getRepository(Poll::class)->findAll();
return $this->render('index.html.twig', [
'polls' => $polls,
]);
}
}