function search_api_entity_delete in Search API 8
Same name and namespace in other branches
- 7 search_api.module \search_api_entity_delete()
Implements hook_entity_delete().
Note that this function implements tracking only on behalf of the "Content Entity" datasource defined in this module, not for entity-based datasources in general. Datasources defined by other modules still have to implement their own mechanism for tracking new/updated/deleted entities.
Independent of datasources, however, this will also call \Drupal\search_api\Utility\TrackingHelper::trackReferencedEntityUpdate() to attempt to mark all items for reindexing that indirectly indexed any fields of this entity.
See also
\Drupal\search_api\Plugin\search_api\datasource\ContentEntityTrackingManager::entityDelete()
File
- ./search_api.module, line 248 
- Provides a rich framework for creating searches.
Code
function search_api_entity_delete(EntityInterface $entity) {
  // Call this hook on behalf of the Content Entity datasource.
  \Drupal::getContainer()
    ->get('search_api.entity_datasource.tracking_manager')
    ->entityDelete($entity);
  // Attempt to track all items as changed that indexed the entity indirectly.
  \Drupal::getContainer()
    ->get('search_api.tracking_helper')
    ->trackReferencedEntityUpdate($entity, TRUE);
}