You are here

public function NodeStorage::delete in Multiversion 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Storage/Sql/NodeStorage.php \Drupal\multiversion\Entity\Storage\Sql\NodeStorage::delete()

@todo: {@link https://www.drupal.org/node/2597534 Figure out why we need this}, core seems to solve it some other way.

Overrides SqlContentEntityStorage::delete

File

src/Entity/Storage/Sql/NodeStorage.php, line 54

Class

NodeStorage
Storage handler for nodes.

Namespace

Drupal\multiversion\Entity\Storage\Sql

Code

public function delete(array $entities) {

  // Delete all menus and comments before deleting the nodes.

  /** @var \Drupal\node\Entity\Node $entity */
  foreach ($entities as $entity) {
    if ($this->moduleHandler
      ->moduleExists('comment')) {
      try {
        comment_entity_predelete($entity);
      } catch (\Exception $e) {

        // We don't want node delete to fail because of broken comments.
      }
    }
    if ($this->moduleHandler
      ->moduleExists('menu_link_content')) {
      try {
        menu_link_content_entity_predelete($entity);
      } catch (\Exception $e) {

        // We don't want node delete to fail because of broken menu links.
      }
    }
  }
  $this
    ->deleteEntities($entities);
}