You are here

public function DomainNavBlock::blockForm in Domain Access 8

Overrides BlockPluginTrait::blockForm

File

domain/src/Plugin/Block/DomainNavBlock.php, line 43

Class

DomainNavBlock
Provides a block that links to all active domains.

Namespace

Drupal\domain\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $defaults = $this
    ->defaultConfiguration();
  $elements['link_options'] = [
    '#title' => $this
      ->t('Link paths'),
    '#type' => 'radios',
    '#required' => TRUE,
    '#options' => [
      'active' => $this
        ->t('Link to active url'),
      'home' => $this
        ->t('Link to site home page'),
    ],
    '#default_value' => !empty($this->configuration['link_options']) ? $this->configuration['link_options'] : $defaults['link_options'],
    '#description' => $this
      ->t('Determines how links to each domain will be written. Note that some paths may not be accessible on all domains.'),
  ];
  $options = [
    'select' => $this
      ->t('JavaScript select list'),
    'menus' => $this
      ->t('Menu-style tab links'),
    'ul' => $this
      ->t('Unordered list of links'),
  ];
  $elements['link_theme'] = [
    '#type' => 'radios',
    '#title' => t('Link theme'),
    '#default_value' => !empty($this->configuration['link_theme']) ? $this->configuration['link_theme'] : $defaults['link_theme'],
    '#options' => $options,
    '#description' => $this
      ->t('Select how to display the block output.'),
  ];
  $options = [
    'name' => $this
      ->t('The domain display name'),
    'hostname' => $this
      ->t('The raw hostname'),
    'url' => $this
      ->t('The domain base URL'),
  ];
  $elements['link_label'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Link text'),
    '#default_value' => !empty($this->configuration['link_label']) ? $this->configuration['link_label'] : $defaults['link_label'],
    '#options' => $options,
    '#description' => $this
      ->t('Select the text to display for each link.'),
  ];
  return $elements;
}