You are here

function devel_generate_delete_menus in Devel 7

Deletes custom generated menus

2 calls to devel_generate_delete_menus()
devel_generate_menu_form_submit in devel_generate/devel_generate.module
FormAPI submission to generate menus.
drush_devel_generate_menus in devel_generate/devel_generate.drush.inc
Command callback. Generate a number of menus and menu links.

File

devel_generate/devel_generate.inc, line 335

Code

function devel_generate_delete_menus() {
  if (module_exists('menu')) {
    foreach (menu_get_menus(FALSE) as $menu => $menu_title) {
      if (strpos($menu, 'devel-') === 0) {
        $menu = menu_load($menu);
        menu_delete($menu);
      }
    }
  }

  // Delete menu links generated by devel.
  $result = db_select('menu_links', 'm')
    ->fields('m', array(
    'mlid',
  ))
    ->condition('m.menu_name', 'devel', '<>')
    ->condition('m.options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE')
    ->execute();
  foreach ($result as $link) {
    menu_link_delete($link->mlid);
  }
}