public function SolrCache::getAsXml in Search API Solr 8.3
Same name and namespace in other branches
- 4.x src/Entity/SolrCache.php \Drupal\search_api_solr\Entity\SolrCache::getAsXml()
Gets the Solr Entity definition as XML fragment.
The XML format is used as part of a solrconfig.xml.
Parameters
bool $add_comment: Wether to add a comment to the XML or not to explain the purpose of this Solr Entity.
Return value
string The Solr RequestHandler definition as XML.
Overrides SolrConfigInterface::getAsXml
File
- src/
Entity/ SolrCache.php, line 98
Class
- SolrCache
- Defines the SolrCache entity.
Namespace
Drupal\search_api_solr\EntityCode
public function getAsXml(bool $add_comment = TRUE) : string {
$comment = '';
if ($add_comment) {
$comment = "<!--\n " . $this
->label() . "\n " . $this
->getMinimumSolrVersion() . "\n-->\n";
}
$copy = $this->cache;
$root = 'cache';
switch ($this->cache['name']) {
case 'filter':
case 'queryResult':
case 'document':
case 'fieldValue':
$root = $this->cache['name'] . 'Cache';
unset($copy['name']);
break;
}
$formatted_xml_string = $this
->buildXmlFromArray($root, $copy);
return $comment . $formatted_xml_string . "\n";
}