You are here

public function SolrFieldType::getCollatedFieldTypeAsJson in Search API Solr 8.3

Same name and namespace in other branches
  1. 4.x src/Entity/SolrFieldType.php \Drupal\search_api_solr\Entity\SolrFieldType::getCollatedFieldTypeAsJson()

Gets the Solr Collated Field Type definition as JSON.

The JSON format is used to interact with a managed Solr schema.

Parameters

bool $pretty: Return pretty printed JSON.

Return value

string The Solr Spellcheck Field Type definition as JSON.

Overrides SolrFieldTypeInterface::getCollatedFieldTypeAsJson

File

src/Entity/SolrFieldType.php, line 316

Class

SolrFieldType
Defines the SolrFieldType entity.

Namespace

Drupal\search_api_solr\Entity

Code

public function getCollatedFieldTypeAsJson(bool $pretty = FALSE) {
  if ($this->collated_field_type) {

    /** @noinspection PhpComposerExtensionStubsInspection */
    return $pretty ? json_encode($this->collated_field_type, JSON_PRETTY_PRINT | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) : Json::encode($this->collated_field_type);
  }
  return '';
}