Esempio n. 1
0
 private function getAllTourVariants()
 {
     $asyncExecutor = new AsyncCurl();
     $dataProvider = new TripDataProvider();
     $items = $dataProvider->getSortedCartItems();
     $grouped = array();
     foreach ($items as $item) {
         if ($item instanceof FlightTripElement) {
             $grouped[$item->getGroupId()][] = $item;
         } else {
             $grouped[$item->getGroupId()][] = $item;
         }
     }
     foreach ($grouped as $group) {
         if ($group[0] instanceof FlightTripElement) {
             $url = FlightTripElement::getUrlToAllVariants($group);
             $asyncExecutor->add($url);
         } else {
             if ($group[0] instanceof HotelTripElement) {
                 $itemVariantsUrl = $group[0]->getUrlToAllVariants();
                 $asyncExecutor->add($itemVariantsUrl);
             }
         }
     }
     $responses = $asyncExecutor->send();
     $this->errors = array();
     $i = 0;
     foreach ($responses as $response) {
         if ($httpCode = $response->headers['http_code'] == 200) {
             $this->variants[$i] = CJSON::decode($response->body);
             $this->errors[$i] = false;
         } else {
             $this->variants[$i] = array();
             $this->errors[$i] = 'Error ' . $httpCode;
         }
         $i++;
     }
 }