You are here

public static function Node::preDelete in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::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 Entity::preDelete

File

core/modules/node/src/Entity/Node.php, line 147
Contains \Drupal\node\Entity\Node.

Class

Node
Defines the node entity class.

Namespace

Drupal\node\Entity

Code

public static function preDelete(EntityStorageInterface $storage, array $entities) {
  parent::preDelete($storage, $entities);

  // Ensure that all nodes deleted are removed from the search index.
  if (\Drupal::moduleHandler()
    ->moduleExists('search')) {
    foreach ($entities as $entity) {
      search_index_clear('node_search', $entity->nid->value);
    }
  }
}