<?php
namespace App\Controller\Front\Product;
use App\Entity\Party;
use App\Repository\PartyRepository;
use App\Service\FrontService;
use App\Service\ParameterService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/front/party', name: 'app_front_party')]
class PartyController extends AbstractController
{
public function __construct(
private readonly FrontService $frontService,
private readonly ParameterService $parameterService,
){}
#[Route('/', name: '_index')]
public function index(PartyRepository $partyRepository): Response
{
$parties = $partyRepository->findParties();
return $this->render('front/party/index.html.twig', [
'parties' => array_filter($parties, function (Party $party) {
return $party->isHotelStayRequired() && !empty($party->getHotelRoomTypeArrangements()->getValues())
|| !$party->isHotelStayRequired();
}),
'society' => $this->parameterService->getSocietyParameters(),
'social_networks' => $this->frontService->getSocialNetworks(),
'agencies' => $this->frontService->getAgencies(),
'currencies' => $this->frontService->getCurrencies(),
]);
}
#[Route('/{partyName}/{city}/{hotelName}/{id}', name: '_detail', methods: ['GET'])]
public function detailParty($id,
PartyRepository $partyRepository,
ParameterService $parameterService
): Response
{
$party = $partyRepository->find($id);
return $this->render('front/party/detail.html.twig', [
'party' => $party,
'validParty' => $party->getDate()->format('Y-m-d') >= date("Y-m-d"),
'society' => $this->parameterService->getSocietyParameters(),
'social_networks' => $this->frontService->getSocialNetworks(),
'agencies' => $this->frontService->getAgencies(),
'currencies' => $this->frontService->getCurrencies(),
]);
}
}