You are here

function block_menu_delete in Drupal 8

Same name and namespace in other branches
  1. 7 modules/block/block.module \block_menu_delete()
  2. 9 core/modules/block/block.module \block_menu_delete()

Implements hook_ENTITY_TYPE_delete() for menu entities.

File

core/modules/block/block.module, line 261
Controls the visual building blocks a page is constructed with.

Code

function block_menu_delete(Menu $menu) {
  if (!$menu
    ->isSyncing()) {
    foreach (Block::loadMultiple() as $block) {
      if ($block
        ->getPluginId() == 'system_menu_block:' . $menu
        ->id()) {
        $block
          ->delete();
      }
    }
  }
}