You are here

function config_pages_menu_links_discovered_alter in Config Pages 8

Same name and namespace in other branches
  1. 8.3 config_pages.module \config_pages_menu_links_discovered_alter()
  2. 8.2 config_pages.module \config_pages_menu_links_discovered_alter()

Implements hook_menu_links_discovered_alter().

File

./config_pages.module, line 117
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);
    $links['config_pages.' . $bundle] = [
      'title' => t($title),
      'parent' => $parent_route_name,
      'route_name' => 'config_pages.' . $bundle,
    ];
  }
}