Skip to content

Instantly share code, notes, and snippets.

@manumilou
Created October 8, 2014 15:25
Show Gist options
  • Save manumilou/0e147082a0a6e2d6a4e7 to your computer and use it in GitHub Desktop.
Save manumilou/0e147082a0a6e2d6a4e7 to your computer and use it in GitHub Desktop.
drupal\features : Delete all menu links before reverting a feature
/**
* Implements hook_pre_features_revert().
*
* If a menu link is added in a menu handled by this feature, it won't be deleted when the menu feature is reverted.
* Only the menu links exported in the feature will be reverted.
* Implementing this hook allows us to make sure that the menu is fully resetted after the revert
* by first deleting all menu links before reverting.
*/
function main_menu_pre_features_revert($component) {
if($component == 'menu_links') {
// Delete all menu links before reverting
menu_delete_links('main-menu');·
}
}
@dooug
Copy link

dooug commented Nov 21, 2014

Thanks for sharing your solution. FYI, there is a rogue · in line 12.
https://gist.github.com/dooug/de2bdf59e068b3d40bb6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment