You are here

public function ContextProximityFilter::getOrigin in Geofield 8

Gets the proximity distance origin.

Return value

array The proximity distance origin.

Overrides GeofieldProximitySourceBase::getOrigin

File

src/Plugin/GeofieldProximitySource/ContextProximityFilter.php, line 68

Class

ContextProximityFilter
Defines 'Geofield Context Filter' plugin.

Namespace

Drupal\geofield\Plugin\GeofieldProximitySource

Code

public function getOrigin() {
  $origin = [];
  if (isset($this->viewHandler)) {

    /** @var \Drupal\geofield\Plugin\views\argument\GeofieldProximityArgument $geofield_proximity_argument */
    $geofield_proximity_argument = $this->viewHandler->view->argument;
    foreach ($this->viewHandler->view->argument as $k => $argument) {
      if ($argument instanceof GeofieldProximityArgument) {
        $geofield_proximity_argument = $argument;
      }
    }
    if (isset($geofield_proximity_argument)) {
      $argument_values = $geofield_proximity_argument
        ->getParsedReferenceLocation();
      $origin = [
        'lat' => $argument_values['lat'],
        'lon' => $argument_values['lon'],
      ];
    }
  }
  return $origin;
}