protected function OgMenuParentFormSelector::getMenuOptions in Organic Groups Menu (OG Menu) 8
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.
Overrides MenuParentFormSelector::getMenuOptions
File
- src/
OgMenuParentFormSelector.php, line 18
Class
Namespace
Drupal\og_menuCode
protected function getMenuOptions(array $menu_names = NULL) {
$entity_type = 'menu';
if ($this->is_og_menu) {
$entity_type = 'ogmenu_instance';
}
/**
* @todo Here we'll need to do some access checks to see if which menus
* belong to the og.
*/
$menus = $this->entityTypeManager
->getStorage($entity_type)
->loadMultiple($menu_names);
$options = array();
/** @var \Drupal\system\MenuInterface[] $menus */
foreach ($menus as $menu) {
if ($this->is_og_menu) {
$options['ogmenu-' . $menu
->id()] = $menu
->label();
}
else {
$options[$menu
->id()] = $menu
->label();
}
}
return $options;
}