public static function Menu::preDelete in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu::preDelete()
- 9 core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu::preDelete()
Acts on entities before they are deleted and before hooks are invoked.
Used before the entities are deleted and before invoking the delete hook.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.
Overrides ConfigEntityBase::preDelete
File
- core/
modules/ system/ src/ Entity/ Menu.php, line 86
Class
- Menu
- Defines the Menu configuration entity class.
Namespace
Drupal\system\EntityCode
public static function preDelete(EntityStorageInterface $storage, array $entities) {
parent::preDelete($storage, $entities);
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
foreach ($entities as $menu) {
// Delete all links from the menu.
$menu_link_manager
->deleteLinksInMenu($menu
->id());
}
}