src/Controller/Front/BookmarkController.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Repository\PartyRepository;
  4. use App\Service\FrontService;
  5. use App\Service\HotelApiService;
  6. use App\Service\ParameterService;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class BookmarkController extends AbstractController
  12. {
  13.     public function __construct(
  14.         private readonly HotelApiService        $hotelApiService,
  15.         private readonly FrontService                    $frontService,
  16.         private readonly ParameterService                $parameterService,
  17.     ){}
  18.     #[Route('/bookmark'name'app_bookmark')]
  19.     public function index(): Response
  20.     {
  21.         return $this->render('front/bookmark/index.html.twig', [
  22.             'controller_name' => 'BookmarkController',
  23.         ]);
  24.     }
  25.     #[Route('/wishList'name'wish_list_for_hotel_products')]
  26.     public function wishListForHotels(Request $request,PartyRepository $partyRepository): Response
  27.     {
  28.         // HOTELS
  29.         $cookies_bookmarked_hotels $request->cookies->get('bookmarkedHotels');
  30.         $bookmarked_hotels json_decode($cookies_bookmarked_hotelstrue);
  31.         $responseHotels = [];
  32.         if (!empty($bookmarked_hotels)) {
  33.             foreach ($bookmarked_hotels as $bookmarked_hotel) {
  34.                 $codeHotel substr(strstr($bookmarked_hotel'-'), 1); // right subString after -
  35.                 $xmlSourceId strstr($bookmarked_hotel'-'true); // left subString before -
  36.                 if ($xmlSourceId == 0) {
  37.                     $hotelDetails $this->hotelApiService->hotelDetails($codeHotel);
  38.                 }
  39.                 else {
  40.                     $hotelDetails $this->hotelApiService->hotelDetailsHUB($bookmarked_hotel);
  41.                 }
  42.                 $responseHotels[] = $hotelDetails;
  43.             }
  44.         }
  45.         // PARTIES
  46.         $responseParties =[];
  47.         $cookieFavoriteParty $request->cookies->get('CookieFavoriteParty');
  48.         $bookmarked_parties json_decode($cookieFavoritePartytrue);
  49.         if (!empty($bookmarked_parties)) {
  50.             foreach ($bookmarked_parties as $bookmarked_party) {
  51.                 $party $partyRepository->find($bookmarked_party);
  52.                 $responseParties[] = $party;
  53.             }
  54.         }
  55.         return $this->render('front/bookmark/wish_list.html.twig',[
  56.             'responseHotels' => $responseHotels,
  57.             'responseParties' => $responseParties,
  58.             'society'           => $this->parameterService->getSocietyParameters(),
  59.             'social_networks'   => $this->frontService->getSocialNetworks(),
  60.             'agencies'          => $this->frontService->getAgencies(),
  61.             'currencies'        => $this->frontService->getCurrencies(),
  62.         ]);
  63.     }
  64. }