You are here

MapFeatureFrontendBase.php in Geolocation Field 8.3

Namespace

Drupal\geolocation

File

src/MapFeatureFrontendBase.php
View source
<?php

namespace Drupal\geolocation;

use Drupal\Core\Render\BubbleableMetadata;

/**
 * Class MapFeatureFrontendBase.
 *
 * @package Drupal\geolocation
 */
abstract class MapFeatureFrontendBase extends MapFeatureBase {

  /**
   * {@inheritdoc}
   */
  public function alterMap(array $render_array, array $feature_settings, array $context = []) {
    $render_array = parent::alterMap($render_array, $feature_settings, $context);
    $render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
      'library' => [
        $this
          ->getPluginDefinition()['provider'] . '/mapfeature.' . $this
          ->getPluginId(),
      ],
      'drupalSettings' => [
        'geolocation' => [
          'maps' => [
            $render_array['#id'] => [
              $this
                ->getPluginId() => [
                'enable' => TRUE,
              ],
            ],
          ],
        ],
      ],
    ]);
    return $render_array;
  }

}

Classes

Namesort descending Description
MapFeatureFrontendBase Class MapFeatureFrontendBase.