Exemplo n.º 1
0
 /**
  * @param array $data An array of data.
  *
  * @return \Geocoder\Model\AddressCollection
  */
 protected function returnResults(array $data = [])
 {
     if (0 < $this->getLimit()) {
         $data = array_slice($data, 0, $this->getLimit());
     }
     return $this->factory->createFromArray($data);
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function reverse($latitude, $longitude)
 {
     $cid = $this->getCacheCid($latitude, $longitude);
     if ($value = $this->cache_get($cid)) {
         return $value;
     }
     try {
         $result = $this->getRandomResult();
         $result['latitude'] = $latitude;
         $result['longitude'] = $longitude;
         $value = $this->factory->createFromArray(array($result));
         $this->cache_set($cid, $value);
     } catch (\Exception $e) {
         $this->loggerChannel->error($e->getMessage(), array('channel' => 'geocoder'));
         $this->messenger->addMessage($e->getMessage(), 'error', FALSE);
         $value = FALSE;
     }
     return $value;
 }
Exemplo n.º 3
0
 /**
  * Create an instance from an array, used from cache libraries.
  *
  * @param array $data
  */
 public function fromArray(array $data = array())
 {
     if (isset($data['providerName'])) {
         $this->providerName = $data['providerName'];
     }
     if (isset($data['query'])) {
         $this->query = $data['query'];
     }
     if (isset($data['exception'])) {
         $this->exception = $data['exception'];
     }
     // Shortcut to create the address and set it in this class
     $addressFactory = new AddressFactory();
     $this->setAddress($addressFactory->createFromArray([$data])->first());
 }