You are here

public function CheeseburgerMenu::buildConfigMenuForm in Cheeseburger Menu 8.4

Builds menu table.

1 call to CheeseburgerMenu::buildConfigMenuForm()
CheeseburgerMenu::blockForm in src/Plugin/Block/CheeseburgerMenu.php
Block form.

File

src/Plugin/Block/CheeseburgerMenu.php, line 393
Cheeseburger class extends BlockBase.

Class

CheeseburgerMenu
Block info.

Namespace

Drupal\cheeseburger_menu\Plugin\Block

Code

public function buildConfigMenuForm($names, $machine_name, $caption) {
  $header = [
    'select' => '',
    'menu' => $this
      ->t('Name'),
    'menu_weight' => $this
      ->t('Weight'),
    'title' => $this
      ->t('Title'),
    'collapsible_title' => $this
      ->t('Collapsible title'),
    'manual_title' => $this
      ->t('Manual title'),
  ];
  $form_part = [
    '#type' => 'table',
    '#caption' => $caption,
    '#header' => $header,
    '#empty' => $this
      ->t('No menus found'),
  ];
  foreach ($names as $id => $name) {
    $form_part[$id] = [
      'select' => [
        '#type' => 'checkbox',
        '#default_value' => array_key_exists($id, $this->configuration[$machine_name]) ? 1 : 0,
      ],
      'menu' => [
        '#markup' => $name,
      ],
      'menu_weight' => [
        '#type' => 'weight',
        '#title_display' => 'invisible',
        '#default_value' => array_key_exists($id, $this->configuration[$machine_name]) ? $this->configuration[$machine_name][$id]['menu_weight'] : 0,
      ],
      'title' => [
        '#type' => 'select',
        '#options' => [
          'do_not_show' => $this
            ->t('Do not show'),
          'use_default' => $this
            ->t('Use default title'),
          'manual' => $this
            ->t('Manual title'),
        ],
        '#title_display' => 'invisible',
        '#default_value' => array_key_exists($id, $this->configuration[$machine_name]) ? $this->configuration[$machine_name][$id]['title'] : 0,
      ],
      'collapsible_title' => [
        '#type' => 'checkbox',
        '#default_value' => array_key_exists($id, $this->configuration[$machine_name]) ? $this->configuration[$machine_name][$id]['collapsible_title'] : 0,
      ],
      'manual_title' => [
        '#type' => 'textfield',
        '#title_display' => 'invisible',
        '#default_value' => array_key_exists($id, $this->configuration[$machine_name]) ? $this->configuration[$machine_name][$id]['manual_title'] : '',
      ],
    ];
  }
  return $form_part;
}