function BlockHooks::menuDelete
Same name and namespace in other branches
- 11.x core/modules/block/src/Hook/BlockHooks.php \Drupal\block\Hook\BlockHooks::menuDelete()
Implements hook_ENTITY_TYPE_delete() for menu entities.
Attributes
#[Hook('menu_delete')]
File
-
core/
modules/ block/ src/ Hook/ BlockHooks.php, line 254
Class
- BlockHooks
- Hook implementations for block.
Namespace
Drupal\block\HookCode
public function menuDelete(Menu $menu) : void {
if (!$menu->isSyncing()) {
foreach (Block::loadMultiple() as $block) {
if ($block->getPluginId() == 'system_menu_block:' . $menu->id()) {
$block->delete();
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.