You are here

public function SolrFieldType::getSolrConfigsAsXml in Search API Solr 8.2

Gets the Solr Field Type specific additions to solrconfig.xml as XML.

The XML format is used as part of a classic Solr solrconf.xml.

Parameters

bool $add_commment: Wether to add a comment to the XML or not to explain the purpose of these configs.

Return value

string The Solr Field Type specific additions to solrconfig.xml as XML.

Overrides SolrFieldTypeInterface::getSolrConfigsAsXml

File

src/Entity/SolrFieldType.php, line 309

Class

SolrFieldType
Defines the SolrFieldType entity.

Namespace

Drupal\search_api_solr\Entity

Code

public function getSolrConfigsAsXml($add_commment = TRUE) {
  $formatted_xml_string = $this
    ->buildXmlFromArray('solrconfigs', $this->solr_configs);
  $comment = '';
  if ($add_commment) {
    $comment = "<!--\n  Special configs for " . $this
      ->label() . "\n  " . ($this
      ->isManagedSchema() ? " for managed schema\n  " : '') . $this
      ->getMinimumSolrVersion() . "\n-->\n";
  }

  // Remove the fake root element the XML fragment.
  return $comment . preg_replace('@</?solrconfigs/?>@', '', $formatted_xml_string);
}