Jan 23, 2018 in Drupal 8, Snippets

I like a good user interface for webmasters, so a clear menu path is necessary. For the admin toolbar dropdowns, I usually create subitems programmatically. Below the code to add a subitem to 'admin/content' ("Content"). You could stick these in a drush script after installation, to get these created automatically after a fresh install of drupal.

use Drupal\menu_link_content\Entity\MenuLinkContent;

MenuLinkContent::create([
  'title' => 'Add content',
  'link' => ['uri' => 'internal:/node/add'],
  'menu_name' => 'admin',
  'weight' => 10,
  'parent' => 'system.admin_content',
])->save();