I'm writing a hook_deploy_N that moves a bunch of menu items from a deprecated custom menu to some newer ones. So far, so good. After moving the items, I want to delete the old menu, but can't figure out how. \Drupal\Core\Menu\MenuTreeStorage has a delete function that may be what I'm looking for, but the \Drupal\Core\Menu\MenuTreeStorage object is housed inside the \Drupal\Core\Menu\MenuLinkTree, which I can at least load, but has protected status, and I don't see a way to get to it. Plus, I'm not not 100% convinced that's what I want any way.

1 Answer 1


Since menus are configuration items, my poking into \Drupal\Core\Menu\MenuTreeStorage::delete() was wrong. You delete a custom menu thusly:


Note that I'm assuming the menu is empty. I don't know what would happen if you deleted a menu that had menu items in it, whether they'd be orphaned or deleted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.