/** * @param $brands * @return FullSearchData */ public function extendBrands($brands) { $em = $this->entityManager; $searchData = $this->searchData; $brandsTransformer = new BrandsToStringTransformer($em); $searchData->brands = $brandsTransformer->reverseTransform($brands); $this->brandsExtended = true; if (count($searchData->getBrands()) > 1) { $this->reservitUtils->setBrandExtender(true); } return $searchData; }
/** * @Route("/process", name="process_advanced_search_form") * @Method("POST") */ public function processAdvancedFormAction(Request $request) { $searchData = $this->get('seh_search_fullsearch_data'); $searchForm = $this->createForm('seh_search_fullsearch', $searchData); $session = $this->get('session'); $searchForm->submit($request); if ($searchForm->isValid()) { $searchDataSession = $this->getSearchData(); $searchString = $searchData->searchString; if ($searchData->searchMapId != '' && $searchData->comeFromSearchMap) { $session->set('searchmapId', $searchData->searchMapId); $locations = array('cities' => array(), 'departments' => array(), 'regions' => array(), 'countries' => array()); foreach (explode(',', $searchData->searchMapId) as $hotelId) { /** @var Hotel $hotel */ $hotel = $this->getRepository('SehBundle:Hotel')->find($hotelId); if ($hotel) { $locations['cities'][$hotel->getCity()->getId()] = $hotel->getCity()->getName(); if ($hotel->getDepartment()) { $locations['departments'][$hotel->getDepartment()->getId()] = $hotel->getDepartment()->getName(); } $locations['regions'][$hotel->getRegion()->getId()] = $hotel->getRegion()->getName(); $locations['countries'][$hotel->getCountry()->getId()] = $hotel->getCountry()->getName(); } } if (count($locations['cities']) == 1) { $location = array_shift($locations['cities']); $searchString = $location; } elseif (count($locations['departments']) == 1) { $location = array_shift($locations['departments']); $searchString = $location; } elseif (count($locations['regions']) == 1) { $location = array_shift($locations['regions']); $searchString = $location; } elseif (count($locations['countries']) == 1) { $location = array_shift($locations['countries']); $searchString = $location; } $session->get('search.data', $searchDataSession); } if (!$searchData->comeFromSearchMap && $searchDataSession) { $searchDataSession->setSearchMapId(''); } if ('' === $searchString) { $searchString = 'no-search-string'; } $roomsTransformer = new RoomsToStringTransformer(); $roomsAsString = $roomsTransformer->transform($searchData->datePax->getSelectedRooms()); $servicesTransformer = new ServicesToStringTransformer($this->getDoctrine()->getManager()); $servicesAsString = $servicesTransformer->transform($searchData->services); $startDate = $searchData->datePax->startingDate->format('Y-m-d'); $endDate = $searchData->datePax->endingDate->format('Y-m-d'); $parameters = array('searchcriteria' => $searchString, 'startdate' => $startDate, 'enddate' => $endDate, 'roomsstring' => $roomsAsString, 'flexible' => !$searchData->flexible_dates ? '0' : '1', 'servicesstring' => $servicesAsString); if ($searchData->accentCard) { $parameters['accentCard'] = $searchData->accentCard; } $route = 'search_form_process_full'; $brandsTransformer = new BrandsToStringTransformer($this->getDoctrine()->getManager()); $brands = $brandsTransformer->transform($searchData->brands); $parameters = array_merge($parameters, array('budgetmin' => $searchData->budget_min, 'budgetmax' => $searchData->budget_max, 'brands' => '' != $brands ? $brands : 'nobrand', 'radius' => $searchData->radius)); $parameters['searchcriteria'] = str_replace('/', '##-##', $parameters['searchcriteria']); return $this->redirect($this->generateUrl($route, $parameters)); } $session->set('form.search.errors', $this->getFormErrorsAsArray($searchForm)); return $this->redirect($this->getRequest()->headers->get('referer')); }