You are here

public function TwitterButtonWidget::getSettingsForm in Twitter Embed 8

Get the settings form for a widget.

It allows the sharing of the configuration among. Block configuration and FieldFormatter configuration.

Parameters

array $configuration: List of selected configuration.

Return value

array The settings form.

Overrides TwitterWidgetInterface::getSettingsForm

File

src/TwitterButtonWidget.php, line 80

Class

TwitterButtonWidget
Class TwitterButtonWidget.

Namespace

Drupal\twitter_embed

Code

public function getSettingsForm(array $configuration) {
  $form = [];

  // @todo handle mention-button extra options like text.
  $form['display_style'] = [
    '#type' => 'radios',
    '#title' => t('Display style'),
    '#options' => $this
      ->getAvailableDisplayStyles(),
    '#default_value' => $configuration['display_style'],
    '#required' => TRUE,
  ];
  $form['display_options'] = [
    '#type' => 'details',
    '#title' => t('Display options'),
    '#open' => FALSE,
  ];
  $form['display_options']['hide_username'] = [
    '#type' => 'checkbox',
    '#title' => t('Hide username'),
    '#default_value' => $configuration['hide_username'],
  ];
  $form['display_options']['hide_followers_count'] = [
    '#type' => 'checkbox',
    '#title' => t('Hide followers count'),
    '#default_value' => $configuration['hide_followers_count'],
  ];
  $form['display_options']['size'] = [
    '#type' => 'checkbox',
    '#title' => t('Large button'),
    '#default_value' => $configuration['size'],
  ];
  $form['display_options']['language'] = [
    '#type' => 'select',
    '#title' => t('Language'),
    '#description' => t('What language would you like to display this in?.'),
    '#options' => $this
      ->getAvailableLanguages(),
    '#default_value' => $configuration['language'],
  ];
  return $form;
}