GeocodeFormatter.php in Geocoder 8.3
File
modules/geocoder_field/src/Plugin/Field/FieldFormatter/GeocodeFormatter.php
View source
<?php
namespace Drupal\geocoder_field\Plugin\Field\FieldFormatter;
use Drupal\geocoder_field\Plugin\Field\GeocodeFormatterBase;
use Drupal\Core\Form\FormStateInterface;
class GeocodeFormatter extends GeocodeFormatterBase {
protected $incompatiblePlugins = [
'file',
'gpxfile',
'kmlfile',
'geojsonfile',
];
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
$compatible_providers = array_filter($element['providers'], function ($e) {
$geocoder_providers = $this->geocoderProviders;
if (isset($geocoder_providers[$e]) && ($geocoder_provider = $geocoder_providers[$e])) {
$plugin = $geocoder_provider
->getPlugin();
return !in_array($plugin
->getPluginId(), $this->incompatiblePlugins);
}
return TRUE;
}, ARRAY_FILTER_USE_KEY);
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;
}
}