Ejemplo n.º 1
0
 /**
  * @param $country_id
  * @param $region_id
  * @param $lang
  * @param $offset
  * @param $city_values
  * @param Grabber $grabber
  * @throws \Exception
  */
 protected static function getCities($country_id, $region_id, $lang, $offset, &$city_values, $grabber)
 {
     try {
         foreach ($grabber->getCities($country_id, $region_id, $offset) as $city) {
             if (!isset($city_values[$city['id']])) {
                 $city_values[$city['id']] = ['city_id' => (int) $city['id'], 'country_id' => (int) $country_id, 'region_id' => (int) $region_id, 'important' => (int) $city['important'], 'name_' . $lang => $city['title']];
             } else {
                 $city_values[$city['id']]['name_' . $lang] = $city['title'];
             }
         }
     } catch (\Exception $c) {
         if (in_array((int) $c->getCode(), [1, 10, 6])) {
             sleep(2);
             get_cities($country_id, $region_id, $lang, $offset, $city_values, $grabber);
         }
         throw new \Exception($c->getMessage(), $c->getCode());
     }
 }