public function GeocodeFormatter::settingsForm in Geocoder 8.3
Same name and namespace in other branches
- 8.2 modules/geocoder_field/src/Plugin/Field/FieldFormatter/GeocodeFormatter.php \Drupal\geocoder_field\Plugin\Field\FieldFormatter\GeocodeFormatter::settingsForm()
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides GeocodeFormatterBase::settingsForm
File
- modules/
geocoder_field/ src/ Plugin/ Field/ FieldFormatter/ GeocodeFormatter.php, line 40
Class
- GeocodeFormatter
- Plugin implementation of the Geocode formatter.
Namespace
Drupal\geocoder_field\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
// Filter out the Geocoder Plugins that are not compatible with the Geocode
// Formatter action.
$compatible_providers = array_filter($element['providers'], function ($e) {
$geocoder_providers = $this->geocoderProviders;
/* @var \Drupal\geocoder\Entity\GeocoderProvider $geocoder_provider */
if (isset($geocoder_providers[$e]) && ($geocoder_provider = $geocoder_providers[$e])) {
/* @var \Drupal\Component\Plugin\PluginBase $plugin */
$plugin = $geocoder_provider
->getPlugin();
return !in_array($plugin
->getPluginId(), $this->incompatiblePlugins);
}
return TRUE;
}, ARRAY_FILTER_USE_KEY);
// Generate a warning markup in case of no compatible Geocoder Provider.
if (count($element['providers']) - count($compatible_providers) == count($this->geocoderProviders)) {
$element['warning'] = [
'#markup' => $this
->t('Any compatible Geocoder Provider available for this Formatter.'),
];
}
$element['providers'] = $compatible_providers;
return $element;
}