function search_api_entity_update in Search API 8
Same name and namespace in other branches
- 7 search_api.module \search_api_entity_update()
Implements hook_entity_update().
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 changed fields of this entity.
See also
\Drupal\search_api\Plugin\search_api\datasource\ContentEntityTrackingManager::entityUpdate()
\Drupal\search_api\Utility\TrackingHelper::trackReferencedEntityUpdate()
File
- ./
search_api.module, line 223 - Provides a rich framework for creating searches.
Code
function search_api_entity_update(EntityInterface $entity) {
// Call this hook on behalf of the Content Entity datasource.
\Drupal::getContainer()
->get('search_api.entity_datasource.tracking_manager')
->entityUpdate($entity);
// Attempt to track all items as changed that indexed updated data indirectly.
\Drupal::getContainer()
->get('search_api.tracking_helper')
->trackReferencedEntityUpdate($entity);
}