You are here

public function UltimenuBlock::blockForm in Ultimenu 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Block/UltimenuBlock.php \Drupal\ultimenu\Plugin\Block\UltimenuBlock::blockForm()

Overrides \Drupal\block\BlockBase::blockForm().

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/UltimenuBlock.php, line 82

Class

UltimenuBlock
Provides an 'Ultimenu' block.

Namespace

Drupal\ultimenu\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  if (\Drupal::currentUser()
    ->hasPermission('administer ultimenu')) {
    $form['skin'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Ultimenu skin'),
      '#default_value' => $this->configuration['skin'],
      '#options' => $this->ultimenuManager
        ->getSkins(),
      '#empty_option' => $this
        ->t('- None -'),
      '#description' => $this
        ->t('Choose the skin for this block. You can supply custom skins at <a href=":ultimenu_settings" target="_blank">Ultimenu settings</a>. The skin can be made specific to this block using the proper class by each menu name. Be sure to <a href=":clear" target="_blank">clear the cache</a> if trouble to see the new skin applied.', [
        ':ultimenu_settings' => Url::fromRoute('ultimenu.settings')
          ->toString(),
        ':clear' => Url::fromRoute('system.performance_settings')
          ->toString(),
      ]),
    ];
    $form['orientation'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Flyout orientation'),
      '#default_value' => $this->configuration['orientation'],
      '#options' => [
        'ultimenu--htb' => t('Horizontal to bottom'),
        'ultimenu--htt' => t('Horizontal to top'),
        'ultimenu--vtl' => t('Vertical to left'),
        'ultimenu--vtr' => t('Vertical to right'),
      ],
      '#description' => $this
        ->t('Choose the orientation of the flyout, depending on the placement. At sidebar left, <strong>Vertical to right</strong>. At header, <strong>Horizontal to bottom</strong>. At footer, <strong>Horizontal to top</strong>'),
    ];
    $form['submenu'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Render submenu'),
      '#default_value' => isset($this->configuration['submenu']) ? $this->configuration['submenu'] : FALSE,
      '#description' => $this
        ->t('Render the relevant submenus inside the Ultimenu region without using Block admin, and independent from blocks. Alternatively use core Menu level option with regular menu block when core supports the "Fixed parent item", see <a href=":url" target="_blank">#2631468</a>. <br /><strong>Important!</strong> Be sure to check "<strong>Show as expanded</strong>" at the parent menu item edit page as needed, otherwise no submenus will be rendered.', [
        ':url' => 'https://www.drupal.org/node/2631468',
      ]),
    ];
    $form['submenu_position'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Submenu position'),
      '#options' => [
        'bottom' => $this
          ->t('Bottom'),
        'top' => $this
          ->t('Top'),
      ],
      '#empty_option' => $this
        ->t('- None -'),
      '#default_value' => isset($this->configuration['submenu_position']) ? $this->configuration['submenu_position'] : '',
      '#description' => $this
        ->t('Choose where to place the submenu, either before or after existing blocks. Default to Top.'),
    ];
  }
  return $form;
}