private function GeofieldMapFieldTrait::getGmapApiKey in Geofield Map 8
Same name and namespace in other branches
- 8.2 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::getGmapApiKey()
Get the GMap Api Key from the geofield_map settings/configuration.
Return value
string The GMap Api Key
6 calls to GeofieldMapFieldTrait::getGmapApiKey()
- GeofieldGoogleMapFormatter::settingsSummary in src/Plugin/ Field/ FieldFormatter/ GeofieldGoogleMapFormatter.php 
- Returns a short summary for the current formatter settings.
- GeofieldMapFieldTrait::preProcessMapSettings in src/GeofieldMapFieldTrait.php 
- Pre Process the MapSettings.
- GeofieldMapFieldTrait::setMapGoogleApiKeyElement in src/GeofieldMapFieldTrait.php 
- Set Map Google Api Key Element.
- GeofieldMapWidget::formElement in src/Plugin/ Field/ FieldWidget/ GeofieldMapWidget.php 
- Implements \Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
- GeofieldMapWidget::settingsForm in src/Plugin/ Field/ FieldWidget/ GeofieldMapWidget.php 
- Returns a form to configure settings for the widget.
File
- src/GeofieldMapFieldTrait.php, line 58 
Class
- GeofieldMapFieldTrait
- Class GeofieldMapFieldTrait.
Namespace
Drupal\geofield_mapCode
private function getGmapApiKey() {
  /* @var \Drupal\Core\Config\ConfigFactoryInterface $config */
  $config = $this->config;
  $geofield_map_settings = $config
    ->getEditable('geofield_map.settings');
  $gmap_api_key = $geofield_map_settings
    ->get('gmap_api_key');
  // In the first release of Geofield_Map the google_api_key was stored in
  // the specific Field Widget settings.
  // So we try and copy into the geofield_map.settings config, in the case.
  if (method_exists(get_class($this), 'getSetting') && !empty($this
    ->getSetting('map_google_api_key')) && empty($gmap_api_key)) {
    $gmap_api_key = $this
      ->getSetting('map_google_api_key');
    $geofield_map_settings
      ->set('gmap_api_key', $gmap_api_key)
      ->save();
  }
  return $gmap_api_key;
}