You are here

function search_api_solr_update_8214 in Search API Solr 8.2

All pre-configured Solr field type configurations will be re-installed as delivered by the module! Please export your existing config before running the update and compare the changes manually, if you modified these configs by yourself!

File

./search_api_solr.install, line 589

Code

function search_api_solr_update_8214() {
  $config_factory = \Drupal::configFactory();
  $settings = $config_factory
    ->get('search_api_solr.settings');
  $raw_data = $settings
    ->getRawData();

  // Unfortunately this function will overwrite search_api_solr.settings, too.
  // Therfore we save it's values bafore and restore them afterwards. In 3.x
  // this "config" is completely migrated to Drupal states.
  search_api_solr_update_helper_install_configs();
  $settings = $config_factory
    ->getEditable('search_api_solr.settings');
  $settings
    ->setData($raw_data)
    ->save(TRUE);
  foreach (search_api_solr_update_helper_get_field_type_configs() as $field_type_name => $field_type_config) {
    if (version_compare($field_type_config['minimum_solr_version'], '7.0.0', '>=') && !empty($field_type_config['field_type']) && !empty($field_type_config['field_type']['analyzers'])) {
      foreach ($field_type_config['field_type']['analyzers'] as &$component) {
        foreach ($component['filters'] as &$filter) {
          switch ($filter['class']) {
            case 'solr.WordDelimiterFilterFactory':
              $filter['class'] = 'solr.WordDelimiterGraphFilterFactory';
              break;
            case 'solr.SynonymFilterFactory':
              $filter['class'] = 'solr.SynonymGraphFilterFactory';
              break;
            case 'solr.StopFilterFactory':
              unset($filter['enablePositionIncrements']);
              break;
          }
        }
      }
    }
    search_api_solr_update_helper_save_field_type_config($field_type_name, $field_type_config);
  }
}