src/Controller/HomeController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Classe\Mail;
  4. use App\Entity\Header;
  5. use App\Entity\Product;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class HomeController extends AbstractController
  11. {
  12.     private $entityManager;
  13.     public function __construct(EntityManagerInterface $entityManager)
  14.     {
  15.         $this->entityManager $entityManager;
  16.     }
  17.     #[Route('/'name'home')]
  18.     public function index(): Response
  19.     {
  20.         
  21.         
  22.         $products $this->entityManager->getRepository(Product::class)->findByIsBest(1);
  23.         $headers $this->entityManager->getRepository(Header::class)->findAll();
  24.         
  25.         return $this->render('home/index.html.twig',[
  26.             
  27.             'produits' => $products,
  28.             'headers'  => $headers
  29.         ]);
  30.         
  31.     }
  32. }