Rename map_name to map_type.
This commit is contained in:
parent
d00a4eb2e1
commit
b026b618aa
|
@ -13,7 +13,7 @@ provider: null
|
|||
plugin: map_block
|
||||
settings:
|
||||
id: dashboard_map
|
||||
map_name: dashboard
|
||||
map_type: dashboard
|
||||
label: 'Dashboard map'
|
||||
provider: farm_map
|
||||
label_display: '0'
|
||||
|
|
|
@ -44,6 +44,6 @@ block.settings.map_block:
|
|||
type: block_settings
|
||||
label: 'map block settings'
|
||||
mapping:
|
||||
map_name:
|
||||
map_type:
|
||||
type: string
|
||||
label: 'Map name'
|
||||
label: 'Map type'
|
||||
|
|
|
@ -18,13 +18,12 @@ class FarmMap extends RenderElement {
|
|||
*/
|
||||
public function getInfo() {
|
||||
$class = get_class($this);
|
||||
$default_name = 'default';
|
||||
return [
|
||||
'#pre_render' => [
|
||||
[$class, 'preRenderMap'],
|
||||
],
|
||||
'#theme' => 'farm_map',
|
||||
'#map_name' => $default_name,
|
||||
'#map_type' => 'default',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -32,8 +31,8 @@ class FarmMap extends RenderElement {
|
|||
* Pre-render callback for the map render array.
|
||||
*
|
||||
* @param array $element
|
||||
* A renderable array containing a #map_name property, which will be used
|
||||
* as the map div ID.
|
||||
* A renderable array containing a #map_type property, which will be
|
||||
* appended to 'farm-map-' as the map element ID.
|
||||
*
|
||||
* @return array
|
||||
* A renderable array representing the map.
|
||||
|
@ -41,12 +40,12 @@ class FarmMap extends RenderElement {
|
|||
public static function preRenderMap(array $element) {
|
||||
|
||||
// Set the id to the map name.
|
||||
$map_id = Html::getUniqueId('farm-map-' . $element['#map_name']);
|
||||
$map_id = Html::getUniqueId('farm-map-' . $element['#map_type']);
|
||||
$element['#attributes']['id'] = $map_id;
|
||||
|
||||
// Get the map type.
|
||||
/** @var \Drupal\farm_map\Entity\MapTypeInterface $map */
|
||||
$map = \Drupal::entityTypeManager()->getStorage('map_type')->load($element['#map_name']);
|
||||
$map = \Drupal::entityTypeManager()->getStorage('map_type')->load($element['#map_type']);
|
||||
|
||||
// Add the farm-map class.
|
||||
$element['#attributes']['class'][] = 'farm-map';
|
||||
|
|
|
@ -20,21 +20,21 @@ class MapBlock extends BlockBase {
|
|||
public function build() {
|
||||
return [
|
||||
'#type' => 'farm_map',
|
||||
'#map_name' => $this->mapName(),
|
||||
'#map_type' => $this->mapType(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that returns the map name.
|
||||
* Function that returns the map type.
|
||||
*
|
||||
* @return string
|
||||
* The map ID.
|
||||
* The map type.
|
||||
*/
|
||||
public function mapName() {
|
||||
public function mapType() {
|
||||
|
||||
// Use the map_name from the block configuration.
|
||||
if (!empty($this->configuration['map_name'])) {
|
||||
return $this->configuration['map_name'];
|
||||
// Use the map_type from the block configuration.
|
||||
if (!empty($this->configuration['map_type'])) {
|
||||
return $this->configuration['map_type'];
|
||||
}
|
||||
|
||||
// Else default to 'default'.
|
||||
|
|
|
@ -111,7 +111,7 @@ class GeofieldFormatter extends FormatterBase {
|
|||
foreach ($features as $delta => $feature) {
|
||||
$element[$delta] = [
|
||||
'#type' => 'farm_map',
|
||||
'#map_name' => 'geofield',
|
||||
'#map_type' => 'geofield',
|
||||
'#map_settings' => [
|
||||
'wkt' => $feature,
|
||||
'behaviors' => [
|
||||
|
|
|
@ -35,7 +35,7 @@ class GeofieldWidget extends GeofieldBaseWidget {
|
|||
// Define the map render array.
|
||||
$element['map'] = [
|
||||
'#type' => 'farm_map',
|
||||
'#map_name' => 'geofield_widget',
|
||||
'#map_type' => 'geofield_widget',
|
||||
'#map_settings' => [
|
||||
'wkt' => $current_value,
|
||||
'behaviors' => [
|
||||
|
|
Loading…
Reference in New Issue