예제 #1
0
 /**
  * @param Hotel $hotel
  * @return bool|string
  */
 public function gmapHotel(Hotel $hotel, $marker, $width = 258, $height = 180)
 {
     $dir = $this->imageDir . 'hotel';
     $imagePath = sprintf('%s/%s-%s-%s.png', $dir, $hotel->getId(), $width, $height);
     if (!file_exists($dir)) {
         $this->filesystem->mkdir($dir);
     }
     if (!file_exists($imagePath)) {
         $gmapImage = sprintf('http://maps.googleapis.com/maps/api/staticmap?center=%s,%s&zoom=14&size=%sx%s&markers=%s%s,%s&sensor=false', $hotel->getLatitude(), $hotel->getLongitude(), $width, $height, $marker ? sprintf('icon:%s%%7C', $marker) : '', $hotel->getLatitude(), $hotel->getLongitude());
         file_put_contents($imagePath, file_get_contents($gmapImage));
     }
     $webPath = strstr($imagePath, 'web/');
     return substr($webPath, 4);
 }
예제 #2
0
 /**
  * @param Hotel $hotel
  *
  * @return $this
  */
 public function updateHotel($hotel)
 {
     $newData = array('brandName' => $hotel->getBrand()->getName(), 'brandSlug' => strtolower($hotel->getBrand()->getArtsysID()), 'name' => $hotel->getName(), 'latLng' => array('lat' => $hotel->getLatitude(), 'lng' => $hotel->getLongitude()), 'active' => $hotel->isValid());
     if ($hotel->getCity()) {
         $newData['cityId'] = sprintf('city%s', $hotel->getCity()->getId());
     }
     try {
         $document = $this->hotelType->getDocument($hotel->getId());
     } catch (NotFoundException $e) {
         $this->addHotel($hotel);
         $document = $this->hotelType->getDocument($hotel->getId());
     }
     $data = $document->getData();
     $newData = array_merge($data, $newData);
     $document->setData($newData);
     $this->hotelType->updateDocument($document);
     return $this;
 }