You are here

public function Location::getAvailableMapCenterOptions in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/geolocation/MapCenter/Location.php \Drupal\geolocation\Plugin\geolocation\MapCenter\Location::getAvailableMapCenterOptions()

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

Parameters

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

Return value

array Available center options indexed by ID.

Overrides MapCenterBase::getAvailableMapCenterOptions

File

src/Plugin/geolocation/MapCenter/Location.php, line 111

Class

Location
Location based map center.

Namespace

Drupal\geolocation\Plugin\geolocation\MapCenter

Code

public function getAvailableMapCenterOptions($context = NULL) {
  $options = [];

  /** @var \Drupal\geolocation\LocationInterface $location_plugin */
  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);
    $location_options = $location_plugin
      ->getAvailableLocationOptions($context);
    if (!$location_options) {
      continue;
    }
    $options[$location_plugin_id] = $location_plugin_definition['name'];
  }
  return $options;
}