public function ContextPopup::alterMap in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/ContextPopup.php \Drupal\geolocation_google_maps\Plugin\geolocation\MapFeature\ContextPopup::alterMap()
Alter render array.
Parameters
array $render_array: Render array.
array $feature_settings: The current feature settings.
array $context: Context like field formatter, field widget or view.
Return value
array Render array.
Overrides MapFeatureBase::alterMap
File
- modules/
geolocation_google_maps/ src/ Plugin/ geolocation/ MapFeature/ ContextPopup.php, line 58
Class
- ContextPopup
- Provides context popup.
Namespace
Drupal\geolocation_google_maps\Plugin\geolocation\MapFeatureCode
public function alterMap(array $render_array, array $feature_settings, array $context = []) {
$render_array = parent::alterMap($render_array, $feature_settings, $context);
$feature_settings = $this
->getSettings($feature_settings);
$token_context = [];
if (!empty($context['view'])) {
$token_context['view'] = $context['view'];
}
if (!empty($settings['content']['value']) && !empty($settings['content']['format'])) {
$content = check_markup(\Drupal::token()
->replace($feature_settings['content']['value'], $token_context), $feature_settings['content']['format']);
}
else {
return $render_array;
}
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'library' => [
'geolocation_google_maps/mapfeature.' . $this
->getPluginId(),
],
'drupalSettings' => [
'geolocation' => [
'maps' => [
$render_array['#id'] => [
$this
->getPluginId() => [
'enable' => TRUE,
'content' => $content,
],
],
],
],
],
]);
return $render_array;
}