public function AbstractSolrEntity::getSolrConfigsAsXml in Search API Solr 8.3
Same name and namespace in other branches
- 4.x src/Entity/AbstractSolrEntity.php \Drupal\search_api_solr\Entity\AbstractSolrEntity::getSolrConfigsAsXml()
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_comment: 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 SolrConfigInterface::getSolrConfigsAsXml
File
- src/
Entity/ AbstractSolrEntity.php, line 173
Class
- AbstractSolrEntity
- Defines the abstract base class for Solr config entities.
Namespace
Drupal\search_api_solr\EntityCode
public function getSolrConfigsAsXml($add_comment = TRUE) {
if (!$this->solr_configs) {
return '';
}
$formatted_xml_string = $this
->buildXmlFromArray('solrconfigs', $this->solr_configs);
$comment = '';
if ($add_comment) {
$comment = "<!--\n Special configs for " . $this
->label() . "\n " . $this
->getMinimumSolrVersion() . "\n-->\n";
}
// Remove the fake root element the XML fragment.
return $comment . trim(preg_replace('@</?solrconfigs/?>@', '', $formatted_xml_string), "\n") . "\n";
}