You are here

public static function Index::postDelete in Search API 8

Acts on deleted entities before the delete hook is invoked.

Used after the entities are deleted but 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 EntityBase::postDelete

File

src/Entity/Index.php, line 1592

Class

Index
Defines the search index configuration entity.

Namespace

Drupal\search_api\Entity

Code

public static function postDelete(EntityStorageInterface $storage, array $entities) {
  parent::postDelete($storage, $entities);
  if (\Drupal::moduleHandler()
    ->moduleExists('views')) {
    Views::viewsData()
      ->clear();

    // Remove this line when https://www.drupal.org/node/2370365 gets fixed.
    Cache::invalidateTags([
      'extension:views',
    ]);
    \Drupal::cache('discovery')
      ->delete('views:wizard');
  }

  /** @var \Drupal\Core\TempStore\SharedTempStore $temp_store */
  $temp_store = \Drupal::service('tempstore.shared')
    ->get('search_api_index');
  foreach ($entities as $entity) {
    try {
      $temp_store
        ->delete($entity
        ->id());
    } catch (TempStoreException $e) {

      // Can't really be helped, I guess. But is also very unlikely to happen.
      // Ignore it.
    }
  }
}