src/Controller/Front/Product/PartyController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front\Product;
  3. use App\Entity\Party;
  4. use App\Repository\PartyRepository;
  5. use App\Service\FrontService;
  6. use App\Service\ParameterService;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. #[Route('/front/party'name'app_front_party')]
  11. class PartyController extends AbstractController
  12. {
  13.     public function __construct(
  14.         private readonly FrontService     $frontService,
  15.         private readonly ParameterService $parameterService,
  16.     ){}
  17.     #[Route('/'name'_index')]
  18.     public function index(PartyRepository $partyRepository): Response
  19.     {
  20.         $parties $partyRepository->findParties();
  21.         return $this->render('front/party/index.html.twig', [
  22.             'parties' => array_filter($parties, function (Party $party) {
  23.                 return $party->isHotelStayRequired() && !empty($party->getHotelRoomTypeArrangements()->getValues())
  24.                     || !$party->isHotelStayRequired();
  25.             }),
  26.             'society'           => $this->parameterService->getSocietyParameters(),
  27.             'social_networks'   => $this->frontService->getSocialNetworks(),
  28.             'agencies'          => $this->frontService->getAgencies(),
  29.             'currencies'        => $this->frontService->getCurrencies(),
  30.         ]);
  31.     }
  32.     #[Route('/{partyName}/{city}/{hotelName}/{id}'name'_detail'methods: ['GET'])]
  33.     public function detailParty($id,
  34.         PartyRepository $partyRepository,
  35.         ParameterService $parameterService
  36.     ): Response
  37.     {
  38.         $party $partyRepository->find($id);
  39.         return $this->render('front/party/detail.html.twig', [
  40.             'party' => $party,
  41.             'validParty' => $party->getDate()->format('Y-m-d') >= date("Y-m-d"),
  42.             'society'           => $this->parameterService->getSocietyParameters(),
  43.             'social_networks'   => $this->frontService->getSocialNetworks(),
  44.             'agencies'          => $this->frontService->getAgencies(),
  45.             'currencies'        => $this->frontService->getCurrencies(),
  46.         ]);
  47.     }
  48. }