You are here

public function MenuExportConfigurationForm::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/MenuExportConfigurationForm.php, line 35

Class

MenuExportConfigurationForm
Configure Menu Export settings.

Namespace

Drupal\menu_export\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('menu_export.settings');
  $menuIds = \Drupal::entityQuery('menu')
    ->execute();
  $menuEntities = Menu::loadMultiple($menuIds);
  foreach ($menuEntities as $menu) {
    $menuNames[$menu
      ->id()] = $menu
      ->label();
  }
  $form['warning'] = [
    '#type' => 'markup',
    '#markup' => $this
      ->t('<strong>Caution:</strong> Select only the menus which are consistent in all the environments(dev,staging,prod).'),
  ];
  $form['menus'] = [
    '#title' => $this
      ->t('Menus to Export'),
    '#type' => 'checkboxes',
    '#options' => $menuNames,
    '#default_value' => $config
      ->get('menus') ? $config
      ->get('menus') : [],
  ];
  return parent::buildForm($form, $form_state);
}