/** * Implements hook_contextual_links_alter(). */ function {{ machine_name }}_contextual_links_alter(array &$links, $group, array $route_parameters) { if ($group == 'menu') { // Dynamically use the menu name for the title of the menu_edit contextual // link. $menu = \Drupal::entityTypeManager()->getStorage('menu')->load($route_parameters['menu']); $links['menu_edit']['title'] = t('Edit menu: @label', ['@label' => $menu->label()]); } }