public function actionCity($query, $airport_req = false, $hotel_req = false) { $cacheKey = 'apiAutocompleteCities4' . md5(serialize(array($query, $airport_req, $hotel_req))); $citiesCache = Yii::app()->cache->get($cacheKey); if ($citiesCache) { $this->send($citiesCache); Yii::app()->end(); } if ($airport_req && $hotel_req) { if ($airport_req > $hotel_req) { $cities = CityManager::getCitiesWithAirportsAndHotels($query); } else { $cities = CityManager::getCitiesWithHotelsAndAirports($query); } } elseif ($airport_req) { $cities = CityManager::getCitiesWithAirports($query); } elseif ($hotel_req) { $cities = CityManager::getCitiesWithHotels($query); } else { $cities = CityManager::getCities($query); } $cities = $this->addMoreInfo($cities); $result = $this->buildResult($query, $cities); Yii::app()->cache->set($cacheKey, $result, appParams('autocompleteCacheTime')); $this->send($result); }
public function actionCityForFlightOrHotel($query, $return = false) { $cities = CityManager::getCitiesWithAirportsAndHotels($query); if ($return) { return $cities; } else { $this->send($cities); } }