openlayers-8.x-4.x-dev/src/Plugin/Control/Rotate/Rotate.php
src/Plugin/Control/Rotate/Rotate.php
<?php
namespace Drupal\openlayers\Plugin\Control\Rotate;
use Drupal\Core\Form\FormStateInterface;
use Drupal\openlayers\Types\Control;
/**
* Defines the Rotate control for an Openlayers map.
*
* @OpenlayersPlugin(
* id = "ol_control_rotate",
* label = @Translation("Rotate"),
* description = @Translation("Define a rotate control."),
* service = "openlayers.Control:Rotate",
* library = "openlayers-plugin-control-rotate",
* is_configurable = "false",
* type = "control"
* )
*/
class Rotate extends Control {
/**
* {@inheritdoc}
*/
public function getSummary() {
$summary = [
'#theme' => 'openlayers_control_summary', // TODO - ???
'#data' => $this->configuration,
];
$summary += parent::getSummary();
return $summary;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'className' => 'ol-rotate',
/*
'coordinateFormat' => NULL,
'projection' => NULL,
'collapsible' => TRUE,
'collapsed' => FALSE,
'tipLabel' => 'Attributions',
'label' => 'aaaaaaaaaaaaaa',
'collapseLabel' => 'bbbbbbbbbbbbbbbb',
*/
];
}
/**
* {@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,
];
/*
$form['collapsible'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Collapsible'),
'#description' => t('Specify if attributions can be collapsed.'),
'#default_value' => $this->configuration['collapsible'],
);
$form['collapsed'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Collapsed'),
'#description' => t('Specify if attributions should be collapsed at startup.'),
'#default_value' => $this->configuration['collapsed'], // Specify if attributions can be collapsed.
);
$form['tipLabel'] = [
'#type' => 'textfield',
'#default_value' => $this->configuration['tipLabel'],
'#title' => t('Tip label'),
'#description' => t('Text label to use for the button tip.'),
'#size' => 100,
'#maxlength' => 100,
'#required' => FALSE,
];
$form['label'] = [
'#type' => 'textfield',
'#default_value' => $this->configuration['label'],
'#title' => t('Label'),
'#description' => t('Text label to use for the collapsed attributions button.'),
'#size' => 100,
'#maxlength' => 100,
'#required' => FALSE,
];
$form['collapseLabel'] = [
'#type' => 'textfield',
'#default_value' => $this->configuration['collapseLabel'],
'#title' => t('Collapse label'),
'#description' => t('Text label to use for the expanded attributions button.'),
'#size' => 100,
'#maxlength' => 100,
'#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');
/*
$this->configuration['collapsible'] = $form_state->getValue('collapsible');
$this->configuration['collapsed'] = $form_state->getValue('collapsed');
$this->configuration['tipLabel'] = $form_state->getValue('tipLabel');
$this->configuration['label'] = $form_state->getValue('label');
$this->configuration['collapseLabel'] = $form_state->getValue('collapseLabel');
*/
}
}
