protected function AbstractSearchApiSolrMultilingualBackend::isPartOfSchema in Search API Multilingual Solr Search 8
Indicates if an 'element' is part of the Solr server's schema.
Parameters
string $kind: The kind of the element, for example 'dynamicFields' or 'fieldTypes'.
string $name: The name of the element.
Return value
bool True if an element of the given kind and name exists, false otherwise.
Throws
\Drupal\search_api_solr_multilingual\SearchApiSolrMultilingualException
2 calls to AbstractSearchApiSolrMultilingualBackend::isPartOfSchema()
- AbstractSearchApiSolrMultilingualBackend::alterSolrDocuments in src/
Plugin/ search_api/ backend/ AbstractSearchApiSolrMultilingualBackend.php - Replaces language unspecific fulltext fields by language specific ones.
- AbstractSearchApiSolrMultilingualBackend::getSchemaLanguageStatistics in src/
Plugin/ search_api/ backend/ AbstractSearchApiSolrMultilingualBackend.php - Gets schema language statistics for the multilingual Solr server.
File
- src/
Plugin/ search_api/ backend/ AbstractSearchApiSolrMultilingualBackend.php, line 473
Class
- AbstractSearchApiSolrMultilingualBackend
- A abstract base class for all multilingual Solr Search API backends.
Namespace
Drupal\search_api_solr_multilingual\Plugin\search_api\backendCode
protected function isPartOfSchema($kind, $name) {
static $previous_calls;
$state_key = 'sasm.' . $this
->getServer()
->id() . '.schema_parts';
$state = \Drupal::state();
$schema_parts = $state
->get($state_key);
// @todo reset that drupal state from time to time
if (!is_array($schema_parts) || empty($schema_parts[$kind]) || !in_array($name, $schema_parts[$kind]) && !isset($previous_calls[$kind])) {
$response = $this
->getSolrConnector()
->coreRestGet('schema/' . strtolower($kind));
if (empty($response[$kind])) {
throw new SearchApiSolrException('Missing information about ' . $kind . ' in response to REST request.');
}
// Delete the old state.
$schema_parts[$kind] = [];
foreach ($response[$kind] as $row) {
$schema_parts[$kind][] = $row['name'];
}
$state
->set($state_key, $schema_parts);
$previous_calls[$kind] = TRUE;
}
return in_array($name, $schema_parts[$kind]);
}