You are here

public function OriginFromProximityFilter::getOrigin in Geofield 8

Gets the proximity distance origin.

Return value

array The proximity distance origin.

Overrides GeofieldProximitySourceBase::getOrigin

File

src/Plugin/GeofieldProximitySource/OriginFromProximityFilter.php, line 155

Class

OriginFromProximityFilter
Defines 'Geofield Custom Origin' plugin.

Namespace

Drupal\geofield\Plugin\GeofieldProximitySource

Code

public function getOrigin() {
  $origin = [];
  if (isset($this->viewHandler) && isset($this->viewHandler->view->filter[$this->viewHandler->options['source_configuration']['source_proximity_filter']]) && is_a($this->viewHandler->view->filter[$this->viewHandler->options['source_configuration']['source_proximity_filter']], '\\Drupal\\geofield\\Plugin\\views\\filter\\GeofieldProximityFilter') && ($source_proximity_filter = $this->viewHandler->options['source_configuration']['source_proximity_filter'])) {

    /** @var \Drupal\geofield\Plugin\views\filter\GeofieldProximityFilter $geofield_proximity_filter */
    $geofield_proximity_filter = $this->viewHandler->view->filter[$source_proximity_filter];
    $source_plugin_id = $geofield_proximity_filter->options['source'];
    $source_plugin_configuration = $geofield_proximity_filter->options['source_configuration'];
    try {

      /** @var \Drupal\geofield\Plugin\GeofieldProximitySourceInterface $source_plugin */
      $source_plugin = $this->proximitySourceManager
        ->createInstance($source_plugin_id, $source_plugin_configuration);
      $source_plugin
        ->setViewHandler($geofield_proximity_filter);
      $origin = $source_plugin
        ->getOrigin();
    } catch (\Exception $e) {
      watchdog_exception('geofield', $e);
    }
  }
  return $origin;
}