entityView($build, $entity, $display, $view_mode); } /** * Implements hook_entity_update(). */ function synonyms_search_entity_update(Drupal\Core\Entity\EntityInterface $entity) { if ($entity instanceof \Drupal\Core\Entity\ContentEntityInterface) { \Drupal::service('synonyms.behavior.search')->entityMarkForReindex($entity); } } /** * Implements hook_entity_delete(). */ function synonyms_search_entity_delete(Drupal\Core\Entity\EntityInterface $entity) { if ($entity instanceof \Drupal\Core\Entity\ContentEntityInterface) { \Drupal::service('synonyms.behavior.search')->entityMarkForReindex($entity); } } /** * Implements hook_ENTITY_TYPE_insert(). */ function synonyms_search_synonym_insert(Drupal\Core\Entity\EntityInterface $entity) { synonyms_search_synonym_reindex($entity); } /** * Implements hook_ENTITY_TYPE_update(). */ function synonyms_search_synonym_update(Drupal\Core\Entity\EntityInterface $entity) { synonyms_search_synonym_reindex($entity); } /** * Implements hook_ENTITY_TYPE_delete(). */ function synonyms_search_synonym_delete(Drupal\Core\Entity\EntityInterface $entity) { synonyms_search_synonym_reindex($entity); } /** * Mark all search index dependent on a given synonym config for reindexing. * * @param \Drupal\synonyms\SynonymInterface $synonym * Synonym config whose dependent search index should be marked for reindexing */ function synonyms_search_synonym_reindex(\Drupal\synonyms\SynonymInterface $synonym) { if ($synonym->get('behavior') == 'synonyms.behavior.search') { $entity_type = \Drupal::entityTypeManager()->getDefinition($synonym->getProviderPluginInstance()->getPluginDefinition()['controlled_entity_type']); $bundle = $synonym->getProviderPluginInstance()->getPluginDefinition()['controlled_bundle']; $query = \Drupal::entityQuery($entity_type->id()); $query->condition($entity_type->getKey('bundle'), $bundle); $result = $query->execute(); \Drupal::service('synonyms.behavior.search')->entityMarkForReindexMultiple(array_values($result), $entity_type->id()); } }