src/Controller/HomepageController.php line 22

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Category;
  4. use App\Entity\Page;
  5. use App\Entity\WarEvent;
  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 HomepageController extends AbstractController
  11. {
  12.     #[Route(
  13.         path'/{_locale<%app.supported_locales%>}',
  14.         name'app_homepage',
  15.         defaults: [
  16.             '_locale' => '%app.default_locale%'
  17.         ]
  18.     )]
  19.     public function index(EntityManagerInterface $emstring $_locale): Response
  20.     {
  21.         $pageRepo $em->getRepository(Page::class);
  22.         $intro $pageRepo->findOneBy(['slug' => 'intro']);
  23.         $about $pageRepo->findOneBy(['slug' => 'about']);
  24.         $categories $em->getRepository(Category::class)->findBy([], ['weight' => 'ASC']);
  25.         return $this->render('homepage/index.html.twig', [
  26.             'intro' => $intro->isVisible() ? $intro null,
  27.             'about' => $about->isVisible() ? $about null,
  28.             'categories' => $categories,
  29.         ]);
  30.     }
  31. }