You are here

public function MenuImportForm::buildForm in Menu Import and Export 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/MenuImportForm.php, line 35

Class

MenuImportForm
Configure Menu Export settings.

Namespace

Drupal\menu_export\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $menus = $this
    ->config('menu_export.settings')
    ->get('menus');
  $menuEnt = Menu::loadMultiple($menus);
  $menuData = array_map(function ($menuEnt) {
    return $menuEnt
      ->label();
  }, $menuEnt);
  $form['menus_to_import'] = [
    '#theme' => 'item_list',
    '#title' => $this
      ->t('Menus to Import'),
    '#items' => $menuData,
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Import Menu Links'),
  ];
  return $form;
}