You are here

public function GoogleMapsProviderBase::getSettingsForm in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_google_maps/src/GoogleMapsProviderBase.php \Drupal\geolocation_google_maps\GoogleMapsProviderBase::getSettingsForm()

Provide a generic map settings form array.

Parameters

array $settings: The current map settings.

array $parents: Form parents.

Return value

array A form array to be integrated in whatever.

Overrides MapProviderBase::getSettingsForm

2 calls to GoogleMapsProviderBase::getSettingsForm()
GoogleMaps::getSettingsForm in modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php
Provide a generic map settings form array.
GoogleStaticMaps::getSettingsForm in modules/geolocation_google_maps/modules/geolocation_google_static_maps/src/Plugin/geolocation/MapProvider/GoogleStaticMaps.php
Provide a generic map settings form array.
2 methods override GoogleMapsProviderBase::getSettingsForm()
GoogleMaps::getSettingsForm in modules/geolocation_google_maps/src/Plugin/geolocation/MapProvider/GoogleMaps.php
Provide a generic map settings form array.
GoogleStaticMaps::getSettingsForm in modules/geolocation_google_maps/modules/geolocation_google_static_maps/src/Plugin/geolocation/MapProvider/GoogleStaticMaps.php
Provide a generic map settings form array.

File

modules/geolocation_google_maps/src/GoogleMapsProviderBase.php, line 198

Class

GoogleMapsProviderBase
Class GoogleMapsProviderBase.

Namespace

Drupal\geolocation_google_maps

Code

public function getSettingsForm(array $settings, array $parents = []) {
  $settings = $this
    ->getSettings($settings);
  $parents_string = '';
  if ($parents) {
    $parents_string = implode('][', $parents) . '][';
  }
  $form = parent::getSettingsForm($settings, $parents);

  /*
   * General settings.
   */
  $form['general_settings'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('General'),
  ];
  $form['height'] = [
    '#group' => $parents_string . 'general_settings',
    '#type' => 'textfield',
    '#title' => $this
      ->t('Height'),
    '#description' => $this
      ->t('Enter the dimensions and the measurement units. E.g. 200px or 100%.'),
    '#size' => 4,
    '#default_value' => $settings['height'],
  ];
  $form['width'] = [
    '#group' => $parents_string . 'general_settings',
    '#type' => 'textfield',
    '#title' => $this
      ->t('Width'),
    '#description' => $this
      ->t('Enter the dimensions and the measurement units. E.g. 200px or 100%.'),
    '#size' => 4,
    '#default_value' => $settings['width'],
  ];
  $form['type'] = [
    '#group' => $parents_string . 'general_settings',
    '#type' => 'select',
    '#title' => $this
      ->t('Default map type'),
    '#options' => $this
      ->getMapTypes(),
    '#default_value' => $settings['type'],
    '#process' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'processGroup',
      ],
      [
        '\\Drupal\\Core\\Render\\Element\\Select',
        'processSelect',
      ],
    ],
    '#pre_render' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'preRenderGroup',
      ],
    ],
  ];
  $form['zoom'] = [
    '#group' => $parents_string . 'general_settings',
    '#type' => 'number',
    '#title' => $this
      ->t('Zoom level'),
    '#description' => $this
      ->t('The initial resolution at which to display the map, where zoom 0 corresponds to a map of the Earth fully zoomed out, and higher zoom levels zoom in at a higher resolution up to 20 for streetlevel.'),
    '#default_value' => $settings['zoom'],
    '#process' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'processGroup',
      ],
    ],
    '#pre_render' => [
      [
        '\\Drupal\\Core\\Render\\Element\\Number',
        'preRenderNumber',
      ],
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'preRenderGroup',
      ],
    ],
  ];
  if ($parents_string) {
    $form['zoom']['#group'] = $parents_string . 'general_settings';
  }
  return $form;
}