src/Controller/GalleryController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Gallery;
  4. use App\Repository\GalleryRepository;
  5. use App\Repository\SectionTitleRepository;
  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 GalleryController extends AbstractController
  11. {
  12.     private $entityManager;
  13.     public function __construct(EntityManagerInterface $entityManager)
  14.     {
  15.         $this->entityManager $entityManager;
  16.     }
  17.     /**
  18.      * @Route("/mediatheque-bilimon-academie", name="app_gallery")
  19.      */
  20.     public function index(SectionTitleRepository $sectionTitleRepositoryGalleryRepository $repository): Response
  21.     {
  22.         $galleryTitle $sectionTitleRepository->findTitleByTag('gallery_index');
  23.         $gallery $repository->findByIsActive(1);
  24.         return $this->render('gallery/index.html.twig', [
  25.             'galleryTitle' => $galleryTitle,
  26.             'galeries' => $gallery
  27.         ]);
  28.     }
  29.     /**
  30.      * @Route("/mediatheque/{slug}", name="app_gallery_show")
  31.      */
  32.     public function show($slug)
  33.     {
  34.         $gallery $this->entityManager->getRepository(Gallery::class)->findOneBySlug($slug);
  35. //        $products = $this->entityManager->getRepository(Product::class)->findByIsBest(1);
  36.         if (!$gallery) {
  37.             return $this->redirectToRoute('app_gallery');
  38.         }
  39.         return $this->render('gallery/show.html.twig', [
  40.             'galeries' => $gallery,
  41. //            'products' => $products
  42.         ]);
  43.     }
  44. }