You are here

public function SolrFieldType::getFieldTypeAsXml in Search API Solr 8.2

Gets the Solr Field Type definition as XML fragment.

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

Parameters

bool $add_commment: Wether to add a comment to the XML or not to explain the purpose of this Solr Field Type.

Return value

string The Solr Field Type definition as XML.

Overrides SolrFieldTypeInterface::getFieldTypeAsXml

File

src/Entity/SolrFieldType.php, line 229

Class

SolrFieldType
Defines the SolrFieldType entity.

Namespace

Drupal\search_api_solr\Entity

Code

public function getFieldTypeAsXml($add_commment = TRUE) {
  $formatted_xml_string = $this
    ->buildXmlFromArray('fieldType', $this->field_type);
  $comment = '';
  if ($add_commment) {
    $comment = "<!--\n  " . $this
      ->label() . "\n  " . ($this
      ->isManagedSchema() ? " for managed schema\n  " : '') . $this
      ->getMinimumSolrVersion() . "\n-->\n";
  }
  return $comment . $formatted_xml_string;
}