You are here

public function GuzzleConnectionDebug::__construct in Elasticsearch Connector 7

Same name and namespace in other branches
  1. 7.5 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::__construct()
  2. 7.2 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::__construct()

Parameters

string $host Host string:

int $port Host port:

array $connectionParams Array of connection parameters:

\Psr\Log\LoggerInterface $log logger object:

\Psr\Log\LoggerInterface $trace logger object (for curl traces):

Return value

\Elasticsearch\Connections\GuzzleConnection

Throws

\Elasticsearch\Common\Exceptions\InvalidArgumentException

File

modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc, line 44

Class

GuzzleConnectionDebug

Namespace

Elasticsearch\Connections

Code

public function __construct($hostDetails, $connectionParams, LoggerInterface $log, LoggerInterface $trace) {
  if (isset($connectionParams['guzzleClient']) !== true) {
    $guzzleOptions = array();
    $guzzleOptions['curl.options']['body_as_string'] = true;
    if (isset($connectionParams['auth']) === true) {
      $guzzleOptions['request.options']['auth'] = $connectionParams['auth'];
    }
    if (!isset($connectionParams['guzzleOptions'])) {
      $connectionParams['guzzleOptions'] = array();
    }
    $connectionParams = array_merge($connectionParams, $connectionParams['guzzleOptions']);
    $this->guzzle = new \Guzzle\Http\Client(null, $guzzleOptions);
  }
  if (isset($hostDetails['port']) !== true) {
    $hostDetails['port'] = 9200;
  }
  if (isset($connectionParams)) {
    $this->connectionOpts = $connectionParams;
  }
  return parent::__construct($hostDetails, $connectionParams, $log, $trace);
}