src/Controller/BranchOfficeController.php line 17

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\BranchOffice;
  4. use App\Repository\AlbumRepository;
  5. use App\Repository\BranchOfficeRepository;
  6. use App\Repository\MenuCardRepository;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. #[Route('/branch_office'name'branch_')]
  11. class BranchOfficeController extends AbstractController
  12. {
  13.     #[Route('/{slug}'name'office')]
  14.     public function index(?BranchOffice $branchOfficeAlbumRepository $albumRepositoryMenuCardRepository $menuCardRepository): Response
  15.     {
  16.         if (!$branchOffice) {
  17.             return $this->redirectToRoute('homepage');
  18.         }
  19.         return $this->render('branch_office/branch_office.html.twig', [
  20.             'branch_office' => $branchOffice,
  21.             'albums' => $albumRepository->findBy(['branchOffice' => $branchOffice]),
  22.             'menus' => $menuCardRepository->findBy(['branchOffice' => $branchOffice]),
  23.         ]);
  24.     }
  25.     #[Route('/{slug}/album/{id}'name'album')]
  26.     public function gallery(string $slugint $idBranchOfficeRepository $branchOfficeRepositoryAlbumRepository $albumRepository)
  27.     {
  28.         //return $this->redirectToRoute('homepage');
  29.         $branchOffice $branchOfficeRepository->findOneBy(['slug' => $slug]);
  30.         $album $albumRepository->findOneBy(['branchOffice' => $branchOffice'id' => $id]);
  31.         return $this->render('branch_office/gallery.html.twig', [
  32.             'album' => $album
  33.         ]);
  34.     }
  35. }