openlayers-8.x-4.x-dev/src/Plugin/Interaction/Translate/Translate.php

src/Plugin/Interaction/Translate/Translate.php
<?php

namespace Drupal\openlayers\Plugin\Interaction\Translate;

use Drupal\Core\Form\FormStateInterface;
use Drupal\openlayers\Openlayers;
use Drupal\openlayers\Types\Interaction;

/**
 * FIX - Insert short comment here.
 *
 * @OpenlayersPlugin(
 *   id = "ol_interaction_translate",
 *   label = @Translation("Translate"),
 *   description = @Translation("Interaction for translating (moving) features."),
 *   service = "openlayers.Interaction:Translate",
 *   library = "openlayers-plugin-interaction-translate",
 *   is_configurable = "true",
 *   type = "interaction"
 * )
 */
class Translate extends Interaction {

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

    $form['options']['select'] = array(
      '#type' => 'select',
      '#title' => t('Select interaction'),
      '#empty_option' => t('- Select an Interaction -'),
      '#default_value' => $this->getOption('select', ''),
      '#description' => t('Select the select interaction.'),
      '#options' => Openlayers::loadAllAsOptions('Interaction'),
      '#required' => TRUE,
    );

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function optionsToObjects() {
    $import = parent::optionsToObjects();

    if ($select = $this->getOption('select')) {
      $select = Openlayers::load('interaction', $select);
      $import = array_merge($select->getCollection()->getFlatList(), $import);
    }

    return $import;
  }

}

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

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