コード例 #1
0
ファイル: HotelController.php プロジェクト: blab2015/seh
 /**
  * @Route("/initialize/{hotel}", name="hotel_from_search")
  * @Method("POST")
  */
 public function fromSearchAction(Request $request, $hotel)
 {
     $form = $this->createForm(new RateSearchType(), $rateSearchData = new RateSearchData());
     $form->submit($request);
     $searchData = $this->getSearchData();
     $searchData->datePax = $rateSearchData->getDatePax();
     $this->container->get('session')->set('search.data', $searchData);
     $hotelRepo = $this->getRepository('SehBundle:Hotel');
     $hotel = $hotelRepo->getValidQueryBuilder()->andWhere('h.reservitId = :id')->setParameter(':id', $hotel)->getQuery()->getOneOrNullResult();
     $rate = $this->getRepository('SehBundle:Reservit\\Rate')->find($rateSearchData->getRateId());
     return new RedirectResponse($this->get('seh.url_manager')->generateHotelUrl($hotel, null, true, $rate));
 }
コード例 #2
0
 /**
  * @Route("/{slug}/process", name="seh_special_rate_process")
  * @Method("POST")
  */
 public function processAction(Request $request, $slug)
 {
     $langContext = $this->get('bigfoot_context')->get('language');
     /** @var QueryBuilder $queryBuilder */
     $queryBuilder = $this->getRepository('SehBundle:Reservit\\RateCategory')->createQueryBuilder('rc');
     $queryBuilder->where('rc.slug = :slug')->setParameter(':slug', $slug);
     $query = $queryBuilder->getQuery();
     $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     try {
         /** @var RateCategory $rateCategory */
         $rateCategory = $query->getOneOrNullResult();
     } catch (\Exception $e) {
         throw new NotFoundHttpException();
     }
     $rateManager = $this->getSpecialRateManager();
     $form = $this->createForm(new RateSearchType(), $rateSearchData = new RateSearchData());
     $form->submit($request);
     if ($form->isValid()) {
         if ($request->isXmlHttpRequest()) {
             $parameters = array('success' => true);
             if ($rateId = $rateSearchData->getRateId()) {
                 $rate = $this->getRepository('SehBundle:Reservit\\Rate')->find($rateId);
                 $hotelId = $request->get('hotelId');
                 /** @var ReservITUtils $reservitUtils */
                 $reservitUtils = $this->get('seh.reservit_utils');
                 $hotel = $this->getRepository('SehBundle:Hotel')->findOneBy(array('reservitId' => $hotelId));
                 $brandContext = $this->get('bigfoot_context')->get('brand', true, strtolower($hotel->getBrand()->getArtsysID()));
                 $hotelAvailRate = $rateManager->isRateAvailable($reservitUtils->requestHotelAvailData($rateSearchData->getDatePax(), $hotelId, array('lang' => $langContext, 'requestor.id' => $brandContext['parameters']['requestor.id'])), $rate);
                 $parameters['html'] = $this->renderView(sprintf('SehBundle:special_rate/includes/popin:%savailable.html.twig', $hotelAvailRate ? '' : 'un'), array('rate' => $rate, 'hotel' => $hotel, 'hotelAvailRate' => $hotelAvailRate));
             }
             return new JsonResponse($parameters);
         }
         if ($this->getRequest()->get('global', false)) {
             $session = $this->get('session');
             /** @var FullSearchData $fullSearchData */
             $fullSearchData = $this->getSearchData();
             $fullSearchData->datePax = $rateSearchData->getDatePax();
             $fullSearchData->accentCard = $rateSearchData->getAccentCard();
             $session->set('search.data', $fullSearchData);
         }
     }
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(array('success' => false, 'errors' => $this->getFormErrorsAsArray($form)));
     }
     return $this->redirect($this->generateUrl('seh_special_rate', array('slug' => $slug)));
 }