How to create a menu with links programmatically in Drupal 8/9

In Drupal 8/9 create a menu by using create() method of the Drupal::entityTypeManager service. Create menu links generated by Drupal\menu_link_content\Entity\MenuLinkContent and create links by using MenuLinkContent::create() function.
copy-icon

Comments

Authors

Read Next