You are here

protected function SearchApiSolrMultilingualBackend::solrRestGet in Apache Solr Multilingual 8

Sends a REST GET request and return the result.

Parameters

string $path The path to append to the base URI:

IndexInterface $index The index whose server the request should be sent to:

Return value

string The decoded response

2 calls to SearchApiSolrMultilingualBackend::solrRestGet()
SearchApiSolrMultilingualBackend::solrDynamicFieldExists in src/Plugin/search_api/backend/SearchApiSolrMultilingualBackend.php
SearchApiSolrMultilingualBackend::solrFieldTypeExists in src/Plugin/search_api/backend/SearchApiSolrMultilingualBackend.php

File

src/Plugin/search_api/backend/SearchApiSolrMultilingualBackend.php, line 336
Contains \Drupal\as_search\Plugin\search_api\backend\ASSearchApiSolrBackend.

Class

SearchApiSolrMultilingualBackend
Plugin annotation @SearchApiBackend( id = "search_api_solr_multilingual", label = @Translation("Solr Multilingual"), description = @Translation("Index items using an Apache Solr Multilingual search server.") )

Namespace

Drupal\apachesolr_multilingual\Plugin\search_api\backend

Code

protected function solrRestGet($path, IndexInterface $index) {
  $uri = $this->solr
    ->getEndpoint()
    ->getBaseUri() . $path;
  $client = \Drupal::service('http_client');
  $result = $client
    ->get($uri, [
    'Accept' => 'application/json',
  ]);
  $output = Json::decode($result
    ->getBody());

  // \Drupal::logger('apachesolr_multilingual')->info(print_r($output, true));
  if (!empty($output['errors'])) {
    throw new SearchApiException("Error trying to send a REST GET request to '{$uri}'" . "\nError message(s):" . print_r($output['errors'], TRUE));
  }
  return $output;
}