You are here

protected function SolrConnectorPluginBase::getDataFromHandler in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getDataFromHandler()
  2. 8 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getDataFromHandler()
  3. 4.x src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getDataFromHandler()

Gets data from a Solr endpoint using a given handler.

Parameters

$endpoint_name:

$handler:

bool $reset: If TRUE the server will be asked regardless if a previous call is cached.

Return value

object A response object with system information.

3 calls to SolrConnectorPluginBase::getDataFromHandler()
SolrConnectorPluginBase::getCoreInfo in src/SolrConnector/SolrConnectorPluginBase.php
Gets information about the Solr Core.
SolrConnectorPluginBase::getLuke in src/SolrConnector/SolrConnectorPluginBase.php
Gets meta-data about the index.
SolrConnectorPluginBase::getServerInfo in src/SolrConnector/SolrConnectorPluginBase.php
Gets information about the Solr server.

File

src/SolrConnector/SolrConnectorPluginBase.php, line 462

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

protected function getDataFromHandler($endpoint_name, $handler, $reset = FALSE) {
  static $previous_calls = [];
  $this
    ->connect();
  $endpoint = $this->solr
    ->getEndpoint($endpoint_name);
  $endpoint_uri = $endpoint
    ->getBaseUri();
  $state_key = 'search_api_solr.endpoint.data';
  $state = \Drupal::state();
  $endpoint_data = $state
    ->get($state_key);
  if (!isset($previous_calls[$endpoint_uri][$handler]) || $reset) {

    // Don't retry multiple times in case of an exception.
    $previous_calls[$endpoint_name] = TRUE;
    if (!is_array($endpoint_data) || !isset($endpoint_data[$endpoint_uri][$handler]) || $reset) {

      // @todo Finish https://github.com/solariumphp/solarium/pull/155 and stop
      // abusing the ping query for this.
      $query = $this->solr
        ->createPing([
        'handler' => $handler,
      ]);
      $endpoint_data[$endpoint_uri][$handler] = $this
        ->execute($query, $endpoint)
        ->getData();
      $state
        ->set($state_key, $endpoint_data);
    }
  }
  return $endpoint_data[$endpoint_uri][$handler];
}