You are here

public function SolrFieldType::getSpellcheckFieldTypeAsJson 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::getSpellcheckFieldTypeAsJson()

Gets the Solr Spellcheck 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::getSpellcheckFieldTypeAsJson

File

src/Entity/SolrFieldType.php, line 293

Class

SolrFieldType
Defines the SolrFieldType entity.

Namespace

Drupal\search_api_solr\Entity

Code

public function getSpellcheckFieldTypeAsJson(bool $pretty = FALSE) {
  if ($this->spellcheck_field_type) {

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