/** * @param array $destinations * [Х][departure] - departure city iata code, * [Х][arrival] - arrival city iata code, * [Х][date] - departure date, * * @param int $adt amount of adults * @param int $chd amount of childs * @param int $inf amount of infanties */ public function actionBE(array $destinations, $adt = 1, $chd = 0, $inf = 0, $format = 'json') { $asyncExecutor = new AsyncCurl(); $this->addBusinessClassAsyncResponse($destinations, $adt, $chd, $inf, $asyncExecutor); $this->addEconomClassAsyncResponse($destinations, $adt, $chd, $inf, $asyncExecutor); $responses = $asyncExecutor->send(); $errors = array(); $variants = array(); foreach ($responses as $response) { if ($httpCode = $response->headers['http_code'] == 200) { $combined = CJSON::decode($response->body); $flights = $combined['flights']; $searchParams = $combined['searchParams']; $variants = CMap::mergeArray($variants, FlightManager::injectForBe($flights, $searchParams)); } else { $errors[] = 'Error ' . $httpCode; } } if (!empty($this->errors)) { $variants = array(); } $flightSearchParams = $this->buildSearchParams($destinations, $adt, $chd, $inf, 'A'); $this->results = $variants; $result['flights']['flightVoyages'] = $this->results; $result['searchParams'] = $flightSearchParams->getJsonObject(); $siblingsEconom = FlightManager::createSiblingsData($flightSearchParams); $result['siblings']['E'] = $siblingsEconom; $this->sendWithCorrectFormat($format, $result); }
public static function injectAdditionalInfo(&$element) { Yii::import('site.common.modules.hotel.models.*'); $hotelClient = new HotelBookClient(); $element['isFlight'] = isset($element['flightKey']); $element['isHotel'] = !isset($element['flightKey']); if ($element['isHotel']) { $element['hotelDetails'] = $hotelClient->hotelDetail($element['hotelId']); } if ($element['isFlight']) { $elements = FlightManager::injectForBe(array($element), $element['searchParams']); $element = $elements[0]; } }