You are here

protected function SolrConnectorPluginBase::createClient in Search API Solr 8.3

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

Create a Client.

2 calls to SolrConnectorPluginBase::createClient()
SolrConnectorPluginBase::connect in src/SolrConnector/SolrConnectorPluginBase.php
Prepares the connection to the Solr server.
SolrConnectorPluginBase::validateConfigurationForm in src/SolrConnector/SolrConnectorPluginBase.php
Form validation handler.

File

src/SolrConnector/SolrConnectorPluginBase.php, line 341

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

protected function createClient(array &$configuration) {
  $configuration[self::QUERY_TIMEOUT] = $configuration['timeout'] ?? 5;
  if (Client::checkMinimal('5.2.0')) {
    $adapter = extension_loaded('curl') ? new Curl($configuration) : new Http($configuration);
    unset($configuration['timeout']);
    return new Client($adapter, $this->eventDispatcher);
  }
  return new Client(NULL, $this->eventDispatcher);
}