You are here

public function GeofieldProximitySourceBase::setUnits in Geofield 8

Set the units to perform the calculation in.

Parameters

string $units: The name of the units constant to be used or string representation of it.

Overrides GeofieldProximitySourceInterface::setUnits

File

src/Plugin/GeofieldProximitySourceBase.php, line 84

Class

GeofieldProximitySourceBase
Base class for Geofield Proximity Source plugins.

Namespace

Drupal\geofield\Plugin

Code

public function setUnits($units) {

  // If the given value is not a valid option, throw an error.
  if (!in_array($units, $this
    ->getUnitsOptions())) {
    $message = $this
      ->t('Invalid units supplied.');
    \Drupal::logger('geofield')
      ->error($message);
    return FALSE;
  }
  else {
    $this->units = $units;
  }
  return TRUE;
}