You are here

public function AddressFieldProvider::isViewsGeoOption in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_address/src/Plugin/geolocation/DataProvider/AddressFieldProvider.php \Drupal\geolocation_address\Plugin\geolocation\DataProvider\AddressFieldProvider::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_address/src/Plugin/geolocation/DataProvider/AddressFieldProvider.php, line 109

Class

AddressFieldProvider
Provides default address field.

Namespace

Drupal\geolocation_address\Plugin\geolocation\DataProvider

Code

public function isViewsGeoOption(FieldPluginBase $views_field) {
  if ($views_field instanceof EntityField) {

    /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager */
    $entityFieldManager = \Drupal::service('entity_field.manager');
    $field_map = $entityFieldManager
      ->getFieldMap();
    if (!empty($field_map) && !empty($views_field->configuration['entity_type']) && !empty($views_field->configuration['field_name']) && !empty($field_map[$views_field->configuration['entity_type']]) && !empty($field_map[$views_field->configuration['entity_type']][$views_field->configuration['field_name']])) {
      if ($field_map[$views_field->configuration['entity_type']][$views_field->configuration['field_name']]['type'] == 'address') {
        return TRUE;
      }
    }
  }
  return FALSE;
}