You are here

search_api_field_map.install in Search API Field Map 8.2

Contains install and update hooks for the Search API Field Map Module.

File

search_api_field_map.install
View source
<?php

/**
 * @file
 * Contains install and update hooks for the Search API Field Map Module.
 */

/**
 * For Federated Search App selected index config, disable use of the system site name
 * token for site name property by default.
 */
function search_api_field_map_update_8101(&$sandbox) {
  $config_factory = \Drupal::configFactory();

  // Get the federated search app config.
  if ($app_config = $config_factory
    ->get('search_api_federated_solr.search_app.settings')) {

    // Determine the id of the selected index.
    $index_id = $app_config
      ->get('index.id');

    // Load mutable index config object.
    // This will create a configuration object if it doesn't already exist.
    $index_config = $config_factory
      ->getEditable('search_api.index.' . $index_id);
    $index_field_settings = $index_config
      ->get('field_settings');

    // If there are added fields and site_name is one of those added fields.
    if (is_array($index_field_settings) && array_key_exists('site_name', $index_field_settings)) {

      // Disable the flag by default.
      $index_config
        ->set('field_settings.site_name.configuration.use_system_site_name', 0);
      $index_config
        ->save(TRUE);
    }
  }
}

Functions

Namesort descending Description
search_api_field_map_update_8101 For Federated Search App selected index config, disable use of the system site name token for site name property by default.