protected function FootermapBlock::getMenus in footermap: a footer site map 8
Get the menus from config storage.
Parameters
string $plugin_id: (Optional) A plugin id for a menu link to use as the top of the menu tree hierarchy.
Return value
array An associative array of menus keyed by menu id (string) and menu label.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to FootermapBlock::getMenus()
- FootermapBlock::blockForm in src/
Plugin/ Block/ FootermapBlock.php - FootermapBlock::buildMap in src/
Plugin/ Block/ FootermapBlock.php - Build content for footer site map.
File
- src/
Plugin/ Block/ FootermapBlock.php, line 343
Class
- FootermapBlock
- Provide a footer-based site map block based on menu items.
Namespace
Drupal\footermap\Plugin\BlockCode
protected function getMenus($plugin_id = NULL) {
$options = [];
// Fetch the menu link by plugin id instead and return that as the menu,
// but use the menu name as the key and the menu link title as the value.
if (isset($plugin_id) && $plugin_id) {
$item = $this->menuLinkManager
->getDefinition($plugin_id, FALSE);
if (!$item) {
return $options;
}
return [
$item['menu_name'] => $item['title'],
];
}
$controller = $this->entityManager
->getStorage('menu');
if ($menus = $controller
->loadMultiple()) {
foreach ($menus as $menu_name => $menu) {
$options[$menu_name] = $menu
->label();
}
asort($options);
}
return $options;
}