You are here

public function Random::geocode in Geocoder 7.2

Geocode data

Parameters

string $data: The data to geocode.

Return value

AddressCollection|FALSE

Overrides Provider::geocode

File

src/Plugin/Geocoder/Provider/Random.php, line 42
The TomTom plugin.

Class

Random
Class Random.

Namespace

Drupal\geocoder\Plugin\Geocoder\Provider

Code

public function geocode($data) {
  $cid = $this
    ->getCacheCid($data);
  if ($value = $this
    ->cache_get($cid)) {
    return $value;
  }
  try {
    $value = $this->factory
      ->createFromArray(array(
      $this
        ->getRandomResult(),
    ));
  } catch (\Exception $e) {
    $this->loggerChannel
      ->error($e
      ->getMessage(), array(
      'channel' => 'geocoder',
    ));
    $this->messenger
      ->addMessage($e
      ->getMessage(), 'error', FALSE);
    $value = FALSE;
  }
  $this
    ->cache_set($cid, $value);
  return $value;
}