You are here

public function Location::getAvailableLocationInputOptions in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/geolocation/LocationInput/Location.php \Drupal\geolocation\Plugin\geolocation\LocationInput\Location::getAvailableLocationInputOptions()

For one LocationInput (i.e. boundary filter), return all options.

Parameters

mixed $context: Context like field formatter, field widget or view.

Return value

array Available center options indexed by ID.

Overrides LocationInputBase::getAvailableLocationInputOptions

File

src/Plugin/geolocation/LocationInput/Location.php, line 95

Class

Location
Location based proximity center.

Namespace

Drupal\geolocation\Plugin\geolocation\LocationInput

Code

public function getAvailableLocationInputOptions($context) {
  $options = [];
  foreach ($this->locationManager
    ->getDefinitions() as $location_plugin_id => $location_plugin_definition) {

    /** @var \Drupal\geolocation\LocationInterface $location_plugin */
    $location_plugin = $this->locationManager
      ->createInstance($location_plugin_id);
    foreach ($location_plugin
      ->getAvailableLocationOptions($context) as $location_id => $location_label) {
      $options[$location_plugin_id . ':' . $location_id] = $location_label;
    }
  }
  return $options;
}