You are here

protected function SolrConnectorPluginBase::createClient in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::createClient()
  2. 8 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 358

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

protected function createClient(array &$configuration) {

  // @todo For backward compatibility we didn't rename 'timeout' yet. We
  // should do so in an update hook.
  $configuration[self::QUERY_TIMEOUT] = $configuration['timeout'] ?? 5;
  unset($configuration['timeout']);
  $adapter = extension_loaded('curl') ? new Curl() : new Http();
  $adapter
    ->setTimeout($configuration[self::QUERY_TIMEOUT]);
  return new Client($adapter, $this->eventDispatcher);
}