Updated: Comment #0

Problem/Motivation

Altering the menu list is messy.
See #2004428: Less ugly operations altering.

Also, this is probably already intended to be done as part of converting to configuration and entities.

Proposed resolution

Use EntityListController for menus

Remaining tasks

Decide if this is a duplicate.
Look at #1891690: Use EntityListController for vocabularies for an example of how to get started (is there a better one?)

User interface changes

No.

API changes

?

#1882552: Deprecate menu_list_system_menus() and menu_ui_get_menus()
#663946: Merge "List links" page into "Edit menu" page
#1891690: Use EntityListController for vocabularies
#2004428-17: Less ugly operations altering
#2023739: menu: hook_entity_operation_alter() does not work with EntityListController

Comments

andypost’s picture

Status: Active » Closed (works as designed)

That's already done
See MenuListController.php

YesCT’s picture

This is from Menu.php

/**
 * Defines the Menu configuration entity class.
 *
 * @EntityType(
 *   id = "menu",
 *   label = @Translation("Menu"),
 *   module = "system",
 *   controllers = {
 *     "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
 *   },
 *   config_prefix = "menu.menu",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label",
 *     "uuid" = "uuid"
 *   }
 * )
 */

I thought I'd see something like:
the "list" controller,
in Vocabulary.php

 *   controllers = {
 *     "storage" = "Drupal\taxonomy\VocabularyStorageController",
 *     "access" = "Drupal\taxonomy\VocabularyAccessController",
 *     "list" = "Drupal\taxonomy\VocabularyListController",
 *     "form" = {
 *       "default" = "Drupal\taxonomy\VocabularyFormController"
 *     }
 *   },
andypost’s picture

Su, but we allow menu module to be disabled so Menu-entity defined in system module and once menu module enabled we use menu_entity_info_alter() to add controllers

YesCT’s picture

oh, I missed that *done* link in #1

Which shows:

/**
 145  * Implements hook_entity_info_alter().
 146  */
 147 function menu_entity_info_alter(&$entity_info) {
 148   $entity_info['menu']['controllers']['list'] = 'Drupal\menu\MenuListController';
 149   $entity_info['menu']['uri_callback'] = 'menu_uri';
 150   $entity_info['menu']['controllers']['form'] = array(
 151     'default' => 'Drupal\menu\MenuFormController',
 152   );
 153 }
YesCT’s picture

OK, since it is using list controllers. the problem is a different one...

#2023739: menu: hook_entity_operation_alter() does not work with EntityListController

YesCT’s picture

Issue summary: View changes

added related issue