public function MenuLinkContentStorage::delete in Multiversion 8
Same name and namespace in other branches
- 8.2 src/Entity/Storage/Sql/MenuLinkContentStorage.php \Drupal\multiversion\Entity\Storage\Sql\MenuLinkContentStorage::delete()
Deletes permanently saved entities.
Parameters
array $entities: An array of entity objects to delete.
Throws
\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.
Overrides EntityStorageInterface::delete
File
- src/
Entity/ Storage/ Sql/ MenuLinkContentStorage.php, line 29
Class
- MenuLinkContentStorage
- Storage handler for menu link content.
Namespace
Drupal\multiversion\Entity\Storage\SqlCode
public function delete(array $entities) {
$this
->deleteEntities($entities);
// Remove the deleted entity as parent for all children.
foreach ($entities as $entity) {
$children = $this
->loadByProperties([
'parent' => $entity
->getPluginId(),
]);
foreach ($children as $child) {
$child->parent->value = '';
$child
->save();
}
}
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
foreach ($entities as $menu_link) {
// Remove link definition from the menu tree storage.
$menu_link_manager
->removeDefinition($menu_link
->getPluginId(), FALSE);
}
}