Skip to content

Instantly share code, notes, and snippets.

@DuaelFr
Created March 29, 2016 10:58
Show Gist options
  • Save DuaelFr/8fac42faa95d2c567470 to your computer and use it in GitHub Desktop.
Save DuaelFr/8fac42faa95d2c567470 to your computer and use it in GitHub Desktop.
D8 menu item expanded by default
/**
* Implements hook_ENTITY_TYPE_presave().
*
* Force the expanded state on menu items in the main menu.
*/
function MYMODULE_menu_link_content_presave(MenuLinkContentInterface $entity) {
if ($entity->get('menu_name')->value == 'main') {
$entity->get('expanded')->set(0, TRUE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment