Follow-up from #2177041: Remove all implementations of hook_menu.

Several uses remain - the need to be re-worked to use the new routing system - the main/difficult one is in views module.

core/modules/comment/comment.module
206: * Implements hook_menu_alter().
208:function comment_menu_alter(&$items) {

core/modules/content_translation/content_translation.module
57: case 'menu_alter':
244: * Implements hook_menu_alter().
249:function content_translation_menu_alter(array &$items) {

core/modules/editor/editor.module
39: * Implements hook_menu_alter().
44:function editor_menu_alter(&$items) {

core/modules/views/views.module
274: * Implement hook_menu_alter().
276:function views_menu_alter(&$callbacks) {

Comments

pwolanin’s picture

pwolanin’s picture

Issue summary: View changes
kylebrowning’s picture

Forgive me for not knowing enough about the issue, but is there a place to find out how the alters should work?

I assume it should handle the way it does now, just alter with new new menu system setup? Example

<?php
/**
 * Implements hook_menu_alter().
 */
function comment_menu_alter(&$items) {
  if (isset($items['admin/content'])) {
    // Add comments to the description for admin/content if any.
    $items['admin/content']['description'] = 'Administer content and comments.';
  }
}

becomes....

<?php
/**
 * Implements hook_menu_alter().
 */
function comment_menu_alter(&$items) {
  if (isset($items['admin.content'])) {
    // Add comments to the description for admin/content if any.
    $items['admin.content']['description'] = 'Administer content and comments.';
  }
}
star-szr’s picture

@kylebrowning I think the change would be much more drastic. If I'm not mistaken the hook_menu_alter() implementations would be replaced with route subscribers, likely extending RouteSubscriberBase.

I'd say \Drupal\field_ui\Routing\RouteSubscriber is probably the best example currently in core.

dawehner’s picture

Status: Active » Fixed

Here is a list of places where we still use hook_menu_alter():

  • comment: This just changes a link description [x] proper usecase
  • content_translation: Change some title and weights [x] proper usecase
  • editor: Rename title/description [x] proper usecase
  • views: add menu links [x] proper usecase

Considering this I will mark the issue as fixed. All actual usecases already use route subscribers.

pwolanin’s picture

well, this is not really fixed until the menu links patch is in

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.