geolocation-8.x-3.x-dev/modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletControlAttribution.php
modules/geolocation_leaflet/src/Plugin/geolocation/MapFeature/LeafletControlAttribution.php
<?php
namespace Drupal\geolocation_leaflet\Plugin\geolocation\MapFeature;
use Drupal\geolocation\Attribute\MapFeature;
use Drupal\geolocation\MapProviderInterface;
use Drupal\geolocation\Plugin\geolocation\MapFeature\ControlElementBase;
/**
* Provides Attribution control element.
*/
#[MapFeature(
id: 'leaflet_control_attribution',
name: new \Drupal\Core\StringTranslation\TranslatableMarkup('Map Control - Attribution'),
description: new \Drupal\Core\StringTranslation\TranslatableMarkup('Add attribution the map.'),
type: 'leaflet'
)]
class LeafletControlAttribution extends ControlElementBase {
/**
* {@inheritdoc}
*/
public static function getDefaultSettings(): array {
return array_replace_recursive(
parent::getDefaultSettings(),
[
'prefix' => 'Leaflet',
]
);
}
/**
* {@inheritdoc}
*/
public function getSettingsForm(array $settings, array $parents = [], ?MapProviderInterface $mapProvider = NULL): array {
$form = parent::getSettingsForm($settings, $parents, $mapProvider);
$form['prefix'] = [
'#type' => 'textfield',
'#title' => $this->t('Prefix'),
'#description' => $this->t('The HTML text shown before the attributions.'),
'#default_value' => $settings['prefix'],
];
return $form;
}
}
