You are here

public function GeocoderFieldPluginManager::getGeocodeSourceFields in Geocoder 8.3

Same name and namespace in other branches
  1. 8.2 modules/geocoder_field/src/GeocoderFieldPluginManager.php \Drupal\geocoder_field\GeocoderFieldPluginManager::getGeocodeSourceFields()

Gets a list of fields available as source for Geocode operations.

Parameters

string $entity_type_id: The entity type id.

string $bundle: The bundle.

string $field_name: The field name.

Return value

array The array of source fields and their label.

File

modules/geocoder_field/src/GeocoderFieldPluginManager.php, line 149

Class

GeocoderFieldPluginManager
The Geocoder Field Plugin manager.

Namespace

Drupal\geocoder_field

Code

public function getGeocodeSourceFields($entity_type_id, $bundle, $field_name) {

  // List the possible Geocoding Field Types.
  $source_fields_types = $this->preprocessorPluginManager
    ->getGeocodeSourceFieldsTypes();

  // Add File and Image field types, for File provider integration.
  if ($this->moduleHandler
    ->moduleExists('image')) {
    array_push($source_fields_types, "file", "image");
  }

  // Add Address and Country Field types, for Address module integration.
  if ($this->moduleHandler
    ->moduleExists('geocoder_address')) {
    array_push($source_fields_types, "address", "address_country");
  }

  // Add Computed field types, for Computed field module integration.
  if ($this->moduleHandler
    ->moduleExists('computed_field')) {
    array_push($source_fields_types, "computed_string", "computed_string_long");
  }

  // Allow other modules to add/alter list of possible Geocoding Field Types.
  $this->moduleHandler
    ->alter('geocode_source_fields', $source_fields_types);
  return $this
    ->getFieldsOptions($entity_type_id, $bundle, $field_name, $source_fields_types);
}