protected function SettingsForm::getMenuOptions in Responsive and off-canvas menu 4.3.x
Same name and namespace in other branches
- 8.3 src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
- 8.2 src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
- 4.4.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
- 4.0.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
- 4.1.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::getMenuOptions()
Gets a list of menu names for use as options.
@noinspection PhpFullyQualifiedNameUsageInspection
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
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to SettingsForm::getMenuOptions()
- SettingsForm::buildForm in src/
Form/ SettingsForm.php - Form constructor.
File
- src/
Form/ SettingsForm.php, line 398
Class
- SettingsForm
- Form builder for the responsive_menu admin settings page.
Namespace
Drupal\responsive_menu\FormCode
protected function getMenuOptions(array $menu_names = NULL) {
$menus = $this->entityTypeManager
->getStorage('menu')
->loadMultiple($menu_names);
$options = [];
/** @var \Drupal\system\MenuInterface[] $menus */
foreach ($menus as $menu) {
$options[$menu
->id()] = $menu
->label();
}
return $options;
}