openlayers-8.x-4.x-dev/src/Plugin/Control/Zoom/Zoom.php

src/Plugin/Control/Zoom/Zoom.php
<?php

namespace Drupal\openlayers\Plugin\Control\Zoom;

use Drupal\openlayers\Types\Control;
use Drupal\Core\Form\FormStateInterface;

/**
 * Defines the Zoom control for an Openlayers map.
 *
 * @OpenlayersPlugin(
 *   id = "ol_control_zoom",
 *   label = @Translation("Zoom"),
 *   description = @Translation("Define a zoom control."),
 *   service = "openlayers.Control:Zoom",
 *   library = "openlayers-plugin-control-zoom",
 *   is_configurable = "false",
 *   type = "control"
 * )
 */
class Zoom extends Control {

  /**
   * {@inheritdoc}
   */
  public function getSummary() {
    $summary = [
      '#theme' => 'openlayers_control_summary',
      '#data' => $this->configuration,
    ];
    $summary += parent::getSummary();

    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'className' => 'ol-zoom',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['className'] = [
      '#type' => 'textfield',
      '#default_value' => $this->configuration['className'],
      '#title' => t('Class name'),
      '#description' => t('CSS class name.'),
      '#size' => 50,
      '#maxlength' => 50,
      '#required' => FALSE,
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);

    $this->configuration['className'] = $form_state->getValue('className');
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc