You are here

protected function SettingsForm::getMenuOptions in Responsive and off-canvas menu 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
  2. 4.4.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
  3. 4.0.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
  4. 4.1.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
  5. 4.3.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()

Gets a list of menu names for use as options.

Parameters

array $menu_names: (optional) Array of menu names to limit the options, or NULL to load all.

Return value

array Keys are menu names (ids) values are the menu labels.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to SettingsForm::getMenuOptions()
SettingsForm::buildForm in src/Form/SettingsForm.php
Form constructor.

File

src/Form/SettingsForm.php, line 342

Class

SettingsForm
Form builder for the responsive_menu admin settings page.

Namespace

Drupal\responsive_menu\Form

Code

protected function getMenuOptions(array $menu_names = NULL) {
  $menus = \Drupal::entityManager()
    ->getStorage('menu')
    ->loadMultiple($menu_names);
  $options = [];

  /** @var \Drupal\system\MenuInterface[] $menus */
  foreach ($menus as $menu) {
    $options[$menu
      ->id()] = $menu
      ->label();
  }
  return $options;
}