You are here

protected function LeafletSettingsElementsTrait::setMapPathOptionsElement in Leaflet 2.1.x

Same name and namespace in other branches
  1. 8 src/LeafletSettingsElementsTrait.php \Drupal\leaflet\LeafletSettingsElementsTrait::setMapPathOptionsElement()
  2. 2.0.x src/LeafletSettingsElementsTrait.php \Drupal\leaflet\LeafletSettingsElementsTrait::setMapPathOptionsElement()

Set Map Geometries Options Element.

Parameters

array $element: The Form element to alter.

array $settings: The Form Settings.

3 calls to LeafletSettingsElementsTrait::setMapPathOptionsElement()
LeafletDefaultFormatter::settingsForm in src/Plugin/Field/FieldFormatter/LeafletDefaultFormatter.php
Returns a form to configure settings for the formatter.
LeafletDefaultWidget::settingsForm in src/Plugin/Field/FieldWidget/LeafletDefaultWidget.php
LeafletMap::buildOptionsForm in modules/leaflet_views/src/Plugin/views/style/LeafletMap.php
Provide a form to edit options for this plugin.

File

src/LeafletSettingsElementsTrait.php, line 689

Class

LeafletSettingsElementsTrait
Class LeafletSettingsElementsTrait.

Namespace

Drupal\leaflet

Code

protected function setMapPathOptionsElement(array &$element, array $settings) {
  $token_replacement_disclaimer = $this->moduleHandler
    ->moduleExists('token') ? $this
    ->t('<b>Note: </b> Using <strong>Replacement Patterns</strong> it is possible to dynamically define the Path geometries options, based on the entity properties or fields values.') : $this
    ->t('<b>Note: </b> Using the @token_module_link it is possible to use <strong>Replacement Patterns</strong> and dynamically define the Path geometries options, based on the entity properties or fields values.', [
    '@token_module_link' => $this->link
      ->generate($this
      ->t('Toke module'), Url::fromUri('https://www.drupal.org/project/token', [
      'absolute' => TRUE,
      'attributes' => [
        'target' => 'blank',
      ],
    ])),
  ]);
  $path_description = $this
    ->t('Set here options that will be applied to the rendering of Map Path Geometries (Lines & Polylines, Polygons, Multipolygons, etc.).<br>Refer to the @polygons_documentation.<br>Note: If empty the default Leaflet path style, or the one choosen and defined in leaflet.api/hook_leaflet_map_info, will be used.<br>@token_replacement_disclaimer', [
    '@polygons_documentation' => $this->link
      ->generate($this
      ->t('Leaflet Path Documentation'), Url::fromUri('https://leafletjs.com/reference-1.0.3.html#path', [
      'absolute' => TRUE,
      'attributes' => [
        'target' => 'blank',
      ],
    ])),
    '@token_replacement_disclaimer' => $token_replacement_disclaimer,
  ]);
  $element['path'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Path Geometries Options'),
    '#rows' => 3,
    '#description' => $path_description,
    '#default_value' => $settings['path'],
    '#placeholder' => $this::getDefaultSettings()['path'],
    '#element_validate' => [
      [
        get_class($this),
        'jsonValidate',
      ],
    ],
  ];
}