You are here

public function SearchApiSolrConnection::__construct in Search API Solr 7

Implements SearchApiSolrConnectionInterface::__construct().

Valid options include:

  • scheme: Scheme of the base URL of the Solr server. Most probably "http" or "https". Defaults to "http".
  • host: The host name (or IP) of the Solr server. Defaults to "localhost".
  • port: The port of the Solr server. Defaults to 8983.
  • path: The base path to the Solr server. Defaults to "/solr/".
  • http_user: If both this and "http_pass" are set, will use this information to add basic HTTP authentication to all requests to the Solr server. Not set by default.
  • http_pass: See "http_user".

Overrides SearchApiSolrConnectionInterface::__construct

File

includes/solr_connection.inc, line 206

Class

SearchApiSolrConnection
Represents a Solr server resource.

Code

public function __construct(array $options) {
  $options += array(
    'scheme' => 'http',
    'host' => 'localhost',
    'port' => 8983,
    'path' => 'solr',
    'http_user' => NULL,
    'http_pass' => NULL,
  );
  $this->options = $options;
  $path = '/' . trim($options['path'], '/') . '/';
  $this->base_url = $options['scheme'] . '://' . $options['host'] . ':' . $options['port'] . $path;

  // Set HTTP Basic Authentication parameter, if login data was set.
  if (strlen($options['http_user']) && strlen($options['http_pass'])) {
    $this->http_auth = 'Basic ' . base64_encode($options['http_user'] . ':' . $options['http_pass']);
  }
}