SearchApiLocationRadius.php in Search API Location 8
File
modules/search_api_location_views/src/Plugin/views/argument/SearchApiLocationRadius.php
View source
<?php
namespace Drupal\search_api_location_views\Plugin\views\argument;
use Drupal\search_api\Plugin\views\SearchApiHandlerTrait;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
class SearchApiLocationRadius extends ArgumentPluginBase {
use SearchApiHandlerTrait;
use SearchApiLocationArgumentTrait;
public function query($group_by = FALSE) {
if (is_numeric($this->argument) && $this->argument > 0) {
$query = $this
->getQuery();
$location_options = (array) $query
->getOption('search_api_location');
$add_options = [
'radius' => $this->argument,
];
$location_field_name = str_replace('__distance', '', $this->realField);
$this
->addFieldOptions($location_options, $add_options, $location_field_name);
$query
->setOption('search_api_location', $location_options);
}
}
}