You are here

public function ProximityFilter::getProximityUnit in Geolocation Field 8

Retrieve proximity unit from configured source.

Return value

string Proximity unit.

2 calls to ProximityFilter::getProximityUnit()
ProximityFilter::defaultExposeOptions in src/Plugin/views/filter/ProximityFilter.php
Provide default options for exposed filters.
ProximityFilter::query in src/Plugin/views/filter/ProximityFilter.php
Add this filter to the query.

File

src/Plugin/views/filter/ProximityFilter.php, line 760

Class

ProximityFilter
Filter handler for search keywords.

Namespace

Drupal\geolocation\Plugin\views\filter

Code

public function getProximityUnit() {
  switch ($this->options['proximity_units']) {
    case 'exposed':
      if (!empty($this->value['units'])) {
        return $this->value['units'];
      }
      break;
    case 'argument':
      $proximity_center = $this
        ->getProximityCenterBySource();
      if (!empty($proximity_center['unit'])) {
        return $proximity_center['unit'];
      }
      break;
    default:
      return $this->options['proximity_units'];
  }
  return 'km';
}