You are here

public function StandardSolrCloudConnector::alterConfigFiles in Search API Solr 8.3

Same name and namespace in other branches
  1. 4.x src/Plugin/SolrConnector/StandardSolrCloudConnector.php \Drupal\search_api_solr\Plugin\SolrConnector\StandardSolrCloudConnector::alterConfigFiles()

Alter the newly assembled Solr configuration files.

Parameters

string[] $files: Array of config files keyed by file names.

string $lucene_match_version: Lucene (Solr) minor version string.

string $server_id: Optional Search API server id. Will be set in most cases but might be empty when the config generation is triggered via UI or drush.

Overrides SolrConnectorPluginBase::alterConfigFiles

File

src/Plugin/SolrConnector/StandardSolrCloudConnector.php, line 307

Class

StandardSolrCloudConnector
Standard Solr Cloud connector.

Namespace

Drupal\search_api_solr\Plugin\SolrConnector

Code

public function alterConfigFiles(array &$files, string $lucene_match_version, string $server_id = '') {
  parent::alterConfigFiles($files, $lucene_match_version, $server_id);

  // Leverage the implicit Solr request handlers with default settings for
  // Solr Cloud.
  // @see https://lucene.apache.org/solr/guide/8_0/implicit-requesthandlers.html
  if (6 !== $this
    ->getSolrMajorVersion()) {
    $files['solrconfig_extra.xml'] = preg_replace("@<requestHandler\\s+name=\"/replication\".*?</requestHandler>@ms", '', $files['solrconfig_extra.xml']);
    $files['solrconfig_extra.xml'] = preg_replace("@<requestHandler\\s+name=\"/get\".*?</requestHandler>@ms", '', $files['solrconfig_extra.xml']);
  }
  else {
    $files['solrconfig.xml'] = preg_replace("@<requestHandler\\s+name=\"/replication\".*?</requestHandler>@ms", '', $files['solrconfig.xml']);
    $files['solrconfig.xml'] = preg_replace("@<requestHandler\\s+name=\"/get\".*?</requestHandler>@ms", '', $files['solrconfig.xml']);
  }
  $files['solrcore.properties'] = preg_replace("/solr\\.replication.*\n/", '', $files['solrcore.properties']);

  // Set the StatsCache.
  // @see https://lucene.apache.org/solr/guide/8_0/distributed-requests.html#configuring-statscache-distributed-idf
  if (!empty($this->configuration['stats_cache'])) {
    $files['solrconfig_extra.xml'] .= '<statsCache class="' . $this->configuration['stats_cache'] . '" />' . "\n";
  }
}