You are here

public function MapRenderEventSubscriber::onMapRender in farmOS 2.x

Same name in this branch
  1. 2.x modules/asset/land/src/EventSubscriber/MapRenderEventSubscriber.php \Drupal\farm_land\EventSubscriber\MapRenderEventSubscriber::onMapRender()
  2. 2.x modules/asset/structure/src/EventSubscriber/MapRenderEventSubscriber.php \Drupal\farm_structure\EventSubscriber\MapRenderEventSubscriber::onMapRender()
  3. 2.x modules/core/map/src/EventSubscriber/MapRenderEventSubscriber.php \Drupal\farm_map\EventSubscriber\MapRenderEventSubscriber::onMapRender()
  4. 2.x modules/core/quantity/src/EventSubscriber/MapRenderEventSubscriber.php \Drupal\quantity\EventSubscriber\MapRenderEventSubscriber::onMapRender()
  5. 2.x modules/core/ui/map/src/EventSubscriber/MapRenderEventSubscriber.php \Drupal\farm_ui_map\EventSubscriber\MapRenderEventSubscriber::onMapRender()
  6. 2.x modules/core/map/modules/mapbox/src/EventSubscriber/MapRenderEventSubscriber.php \Drupal\farm_map_mapbox\EventSubscriber\MapRenderEventSubscriber::onMapRender()

React to the MapRenderEvent.

Parameters

\Drupal\farm_map\Event\MapRenderEvent $event: The MapRenderEvent.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

modules/core/quantity/src/EventSubscriber/MapRenderEventSubscriber.php, line 51

Class

MapRenderEventSubscriber
An event subscriber for the MapRenderEvent.

Namespace

Drupal\quantity\EventSubscriber

Code

public function onMapRender(MapRenderEvent $event) {

  // Set a cache tag on the quantity settings in case this ever changes.
  $event
    ->addCacheTags([
    'config:quantity.settings',
  ]);

  // Add the system of measurement to drupalSettings.farm_map.units.
  $measurement = $this->configFactory
    ->get('quantity.settings')
    ->get('system_of_measurement');
  $event->element['#attached']['drupalSettings']['farm_map']['units'] = $measurement;
}