You are here

public function Location::getSettingsForm in Geolocation Field 8.2

Same name in this branch
  1. 8.2 src/Plugin/geolocation/MapCenter/Location.php \Drupal\geolocation\Plugin\geolocation\MapCenter\Location::getSettingsForm()
  2. 8.2 src/Plugin/geolocation/LocationInput/Location.php \Drupal\geolocation\Plugin\geolocation\LocationInput\Location::getSettingsForm()
Same name and namespace in other branches
  1. 8.3 src/Plugin/geolocation/LocationInput/Location.php \Drupal\geolocation\Plugin\geolocation\LocationInput\Location::getSettingsForm()

Settings form by ID and context.

Parameters

int $center_option_id: LocationInput option ID.

array $settings: The current option settings.

mixed $context: Current context.

Return value

array A form array to be integrated in whatever.

Overrides LocationInputBase::getSettingsForm

File

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

Class

Location
Location based proximity center.

Namespace

Drupal\geolocation\Plugin\geolocation\LocationInput

Code

public function getSettingsForm($option_id = NULL, array $settings = [], $context = NULL) {
  $values = explode(':', $option_id);
  if (count($values) !== 2) {
    return [];
  }
  $location_plugin_id = $values[0];
  $location_option_id = $values[1];
  if (!$this->locationManager
    ->hasDefinition($location_plugin_id)) {
    return [];
  }

  /** @var \Drupal\geolocation\LocationInterface $location_plugin */
  $location_plugin = $this->locationManager
    ->createInstance($location_plugin_id);
  $form = parent::getSettingsForm($location_plugin
    ->getPluginId(), $settings, $context);

  // A bit more complicated to use location schema.
  $form['location_settings']['settings'] = $location_plugin
    ->getSettingsForm($location_option_id, $settings['location_settings']['settings'], $context);
  $form['location_plugin_id'] = [
    '#type' => 'value',
    '#value' => $location_plugin_id,
  ];
  return $form;
}