You are here

public function SolrRequestDispatcher::getAsXml in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Entity/SolrRequestDispatcher.php \Drupal\search_api_solr\Entity\SolrRequestDispatcher::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/SolrRequestDispatcher.php, line 105

Class

SolrRequestDispatcher
Defines the SolrRequestDispatcher entity.

Namespace

Drupal\search_api_solr\Entity

Code

public function getAsXml(bool $add_comment = TRUE) : string {
  $comment = '';
  if ($add_comment) {
    $comment = "<!--\n  " . $this
      ->label() . "\n  " . $this
      ->getMinimumSolrVersion() . "\n-->\n";
  }
  $copy = $this->request_dispatcher;
  $root = $this->request_dispatcher['name'];
  unset($copy['name']);
  $formatted_xml_string = $this
    ->buildXmlFromArray($root, $copy);
  return $comment . $formatted_xml_string . "\n";
}