1.20.x layout.module layout_modules_uninstalled($modules)

Implements hook_modules_uninstalled()

Deletes all blocks provided by a module when that module is uninstalled.

File

modules/layout/layout.module, line 2048
The Layout module creates pages and wraps existing pages in layouts.

Code

function layout_modules_uninstalled($modules) {
  $layouts = layout_load_all();
  foreach ($modules as $module) {
    foreach ($layouts as $layout) {
      $blocks_to_remove = array();
      foreach ($layout->content as $uuid => $block) {
        if ($block->module == $module) {
          $blocks_to_remove[] = $uuid;
        }
      }
      if ($blocks_to_remove) {
        foreach ($blocks_to_remove as $uuid_to_remove) {
          $layout->removeBlock($uuid_to_remove);
        }
        $layout->save();
      }
    }
  }
}