function config_pages_menu_links_discovered_alter in Config Pages 8.2
Same name and namespace in other branches
- 8.3 config_pages.module \config_pages_menu_links_discovered_alter()
- 8 config_pages.module \config_pages_menu_links_discovered_alter()
Implements hook_menu_links_discovered_alter().
File
- ./
config_pages.module, line 144 - Module hooks.
Code
function config_pages_menu_links_discovered_alter(&$links) {
$config_pages_types = \Drupal::entityTypeManager()
->getStorage('config_pages_type')
->loadMultiple();
foreach ($config_pages_types as $page_type) {
$bundle = $page_type
->getOriginalId();
$menu_path = $page_type->menu['path'];
$title = $page_type
->label();
$parent_route_name = config_pages_find_parent_route_name($menu_path);
$description = !empty($page_type->menu['description']) ? t($page_type->menu['description']) : '';
$weight = !empty($page_type->menu['weight']) ? $page_type->menu['weight'] : 0;
$links['config_pages.' . $bundle] = [
'title' => t($title),
'description' => $description,
'parent' => $parent_route_name,
'route_name' => 'config_pages.' . $bundle,
'enabled' => TRUE,
'weight' => $weight,
];
}
}