You are here

function elasticsearch_connector_search_api_entity_presave in Elasticsearch Connector 7.2

Same name and namespace in other branches
  1. 7.5 modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module \elasticsearch_connector_search_api_entity_presave()
  2. 7 modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module \elasticsearch_connector_search_api_entity_presave()

Implementation of hook_entity_presave().

Parameters

object $entity:

string $entity_type:

File

modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module, line 275
Provides a elasticsearch-based service class for the Search API.

Code

function elasticsearch_connector_search_api_entity_presave($entity, $entity_type) {
  if ('search_api_index' == $entity_type) {

    // If we are saving an index with elasticsearch server, unset all processors.
    $server = $entity
      ->server();
    if (!empty($server) && $server->class == 'search_api_elasticsearch_connector') {
      if (!empty($entity->options['processors'])) {
        foreach ($entity->options['processors'] as $proc_key => $proc_options) {
          if (strpos($proc_key, 'search_api_elasticsearch') === FALSE) {
            $entity->options['processors'][$proc_key]['status'] = 0;
          }
        }
      }
    }
  }
}