You are here

public function SearchAPI::isViewsGeoOption in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 modules/geolocation_search_api/src/Plugin/geolocation/DataProvider/SearchAPI.php \Drupal\geolocation_search_api\Plugin\geolocation\DataProvider\SearchAPI::isViewsGeoOption()

Determine valid views option.

Parameters

\Drupal\views\Plugin\views\field\FieldPluginBase $views_field: Views field definition.

Return value

bool Yes or no.

Overrides DataProviderBase::isViewsGeoOption

File

modules/geolocation_search_api/src/Plugin/geolocation/DataProvider/SearchAPI.php, line 27

Class

SearchAPI
Provides Google Maps.

Namespace

Drupal\geolocation_search_api\Plugin\geolocation\DataProvider

Code

public function isViewsGeoOption(FieldPluginBase $views_field) {
  if ($views_field instanceof SearchApiEntityField) {
    $index_id = str_replace('search_api_index_', '', $views_field->table);
    $index = Index::load($index_id);
    if (empty($index)) {
      return FALSE;
    }

    /** @var \Drupal\search_api\Item\FieldInterface $search_api_field */
    $search_api_field = $index
      ->getField($views_field->field);
    if (empty($search_api_field)) {
      return FALSE;
    }
    elseif ($search_api_field
      ->getType() == 'location') {
      return TRUE;
    }
  }
  return FALSE;
}